Can't seem to assign value to (new) variable within IF statement, Syntax Error on Token: 'EQUAL'

First off, i apologize as i do need to get to reading more and figure these out on my own, but i’m on a mission here so any help is appreciated.

This is an expression linked to the background color in a multi state indicator.

I think the code should be pretty self explanatory, but obviously i am not getting something right.

“Syntax Error on Token: ‘EQUAL’” is the error i’m getting.

if({[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13} && !{[default]200FT Stripper/SS_PB/17SS_STRIPPER-HAND-S-END_I6-12},
	northHandOnly = 1,
	northHandOnly = 0
)

if(!{[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13} && {[default]200FT Stripper/SS_PB/17SS_STRIPPER-HAND-S-END_I6-12},
	southHandOnly = 1,
	southHandOnly = 0
)

if(northHandOnly || southHandOnly,
	color (71,255,71),
	color (255,10,10)
)

Ignition expressions cannot do assignments. They are just expressions. An assignment to the bound property is implied (Imagine that property and an equal sign to the left of your first character in your expression).

2 Likes

I see, so in that case would i be able to use nested statements to accomplish the same thing?

I would use intermediate custom properties in place of the variables you’re using. Make boolean custom properties northHandOnly and southHandOnly on the indicator. Give them the conditions you have in the if blocks at the top.
Then for the color, bind it using the last if statement you have, but using the custom properties in the condition.

1 Like

Not statements. Expressions. I'd do as Paul suggested, but you can make it a single expression if you don't mind multiple references to the same tags.

1 Like

Assuming that 17SS_STRIPPER-HAND-S-END_I6-12 is a boolean, I don’t see the point in checking whether it is true or false, when in each scenario you are setting another bit to true and then ultimately if either of the resulting bits are true you are ending up a with the same color. You could strip your code down to a much simpler expression:

if({[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13},
	color (71,255,71),
	color (255,10,10)
)

It clearly excludes when both signals are on.

I missed that exclamation point before the first tag in the second if statement. Ignore my previous post. :slight_smile:

1 Like