Expression Binding Syntax

I am using an expression to bind data to an objects status and I am getting the following error. I am using the hot keys on the side for operators and such, so I am lost to the issue.

fillingLineID = String
sourceTank4X1 = INT
tankDisplayed = INT

Syntax Error on Token: 'EQUAL' (Line 1 , Char 36)

with this syntax

if({Root Container.fillingLineId} = '1' && {Root Container.sourceTank4X1} = 2 ** ({Root Container.tankDisplayed} - 1), 1, 0)

Thanks!

The power operator:

  • Python: **.
  • Expression language: ^.

https://docs.inductiveautomation.com/display/DOC81/Expression+Language+and+Syntax#ExpressionLanguageandSyntax-Operators

You copied the syntax from my answer to your previous question but that was a script, not an expression.

You're correct. Why did the error point to the first = sign instead of the **syntax error?

I don't know other than the equality operation failed.

By the way, the expression interpreter is very accomodating of line breaks and comments so you can write them in a way that's easy to read.

if(
    // Ignore other lines.
    {Root Container.fillingLineId} = '1'    
    && 
    // Check the binary index ...
    {Root Container.sourceTank4X1} = 2 ^ ({Root Container.tankDisplayed} - 1),
    1,     // Would 'true' be more appropriate here?
    0     //  And 'false' here?
)

If you are able to use true and false then your expression becomes:

{Root Container.fillingLineId} = '1'    
&& 
{Root Container.sourceTank4X1} = 2 ^ ({Root Container.tankDisplayed} - 1)

... which will return a true if both statements are true.

3 Likes