Function not 'exiting' as expected

if not function excel
which one is not a function in ms excel sum avg max min
or function excel
excel not equal
use the not function in cell j11 to determine if there are not 2 outs
not function definition
excel is not blank
which function in excel checks whether a condition is true or not

I've (in Umbraco) a parent node, a child of the parent and a child of the child. All three nodes shared a comment property, it's possible that all 3 nodes will have this property populated or any combination thereof.

Basically I need to know the current node that I'm looking at has this property populated and if not then check the parent and so on recursively up the tree.

So I've written the following method:

    public int getRecursiveNodePropertyParent (Node targetNode, string alias)
    {
        //does this node have the property?
        var found = getNodeProperty(targetNode.Id, alias);

        if (found == "")
        {
            Node myparentNode = new Node(targetNode.Parent.Id);
            getRecursiveNodePropertyParent(myparentNode, alias);
        }
        else
        {
            return Int32.Parse(targetNode.Id.ToString());
        }

        return 0;
    }

If the current page that I'm viewing has the property populated then the function works fine but if the current page doesn't have the property but it's parent does then the function doesn't work as expected.

Basically what happens is this: 1) It checks the current page and finds nothing 2) It then recalls the function passing in the parent of the current page 3) It finds the value and hits 'return Int32.Parse(targetNode.Id.ToString());' 4) It then continues checking up the tree * i.e. it then hits the line 'getRecursiveNodePropertyParent(myparentNode, alias);'

  • This is what I don't understand as surely when the line 'return Int32.Parse(targetNode.Id.ToString());' should cause the routine to exit and return the correct ID but the code block doesn't exit.

Could someone point me in the right direction please?

Thanks, C

You don't do anything with the return value of the recursive call. Then execution continues through the function, eventually returning 0. It looks like you want to return it:

// ...
if (found == "")
{
    Node myparentNode = new Node(targetNode.Parent.Id);
    return getRecursiveNodePropertyParent(myparentNode, alias);
 // ^^^^^^
}
else
{
    return Int32.Parse(targetNode.Id.ToString());
}

You can even get rid of the return 0; at the end now, since both branches of the if-else return a value.

Excel formula: If cell is not blank, The NOT function is a built-in function in Excel that is categorized as a Logical Function. It can be used as a worksheet function (WS) in Excel. As a worksheet  The NOT function is an Excel Logical function. The function helps check if one value is not equal to another. If we give TRUE, it will return FALSE and when given FALSE, it will return TRUE.

In your code, you are not returning in

getRecursiveNodePropertyParent(myparentNode, alias);

instead it goes on and hits the last line with

return 0;

Maybe you should return the value of the first? I don't know the rest of your code, but maybe that's already it.

When logical is TRUE, NOT returns FALSE. A common use case for NOT is to reverse the behavior of another function. For example, If the cell A1 is blank, then the  Start studying Function or Not a Function?. Learn vocabulary, terms, and more with flashcards, games, and other study tools.

Umbraco has this functionality out of the box, no need for any additional code.

Assuming you're using V6 or V7 rather than use the Node representation of the content, use IPublishedContent, that has a method called GetPropertyValue that you can tell to recurse up the tree. So for example you can do something like:

var propertyValue = content.GetPropertyValue<string>("myAlias", recursive: true);

Which will mean that propertyValue will have the value of the content node if it's set, otherwise it'll automatically recurse up the tree for you and look for it.

equal to another. If we give TRUE, it will return FALSE and when given FALSE, it will return TRUE. So, basically, it will always return a reverse logical value. Is this graph a function or not a function? Function Or Not? DRAFT. 7th - 9th grade. 1207 times. Mathematics. 80% average accuracy. 2 years ago. hnwilliams13. 2. Save

The NOT function is an Excel Logical function. The function helps check if one value is not equal to another. If we give TRUE, it will return FALSE and when  @mcgrailm - You're not trying to use the function from an outer scope (e.g. inline onclick handler)even binding the click handlers inside the document.ready would work here, but a reference to a global function not scoped as such won't work. – Nick Craver ♦ Sep 22 '10 at 20:40

The Microsoft Excel NOT function returns the reversed logical value of its arguments, that is, if Duration: 2:54 Posted: Oct 14, 2015 Use the NOT function to reverse a value or logical argument: When logical is FALSE, NOT returns TRUE. When logical is TRUE, NOT returns FALSE. A common use case for NOT is to reverse the behavior of another function. For example, If the cell A1 is blank, then the formula =ISBLANK(A1) will return TRUE.

To be a function or not to be a function. To be a function or not to be a function Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website.

Comments
  • same idea as I had :)
  • Genius! Thank you my friend! :)