Jump to content

Unable to evaluate expression - basic if condition


babbel

Recommended Posts

Hello everyone,

 

I get this expression error but I can't figure why.

Can someone please tell what i'm doing wrong ? Or maybe it's not possible to do that in this field ?

if(ch("../depth")<5){ch("../depth")*4)+1}else{ch("../depth")*3)+1}

image.png.03ccff868a6cb39b3fdba5dd100526db.png

 

Thank you,

 

Baptiste

Link to comment
Share on other sites

There is parentheses mismatch in the original expression, which will break any code.

If you want to use classic C-like if (cond) {statement} else {statement}, you need to open full editor via RMB menu and use multi-line expression (it is like a function body without function declaration itself):

{
    if (ch("../depth") < 5)
    {
        return ch("../depth") * 4 + 1;
    }
    else
    {
        return ch("../depth") * 3 + 1;
    }
}

What you used is if() expression function. I think it just wraps code above into something that is easier to use inside expressions. Although it evaluates both branches, I doubt if anyone ever had problems with it in practice.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...