I need help understanding what this expression is doing. specifically the (&8192) portion. This is in a visibility animation on a label in RSView SE. I'm trying to rebuild this into a visible property on a label in Ignition but its not working and i don't understand what its trying to do.
I understand it up until ({#4\ConfigWord} & 8192) but I don't use bitwise operators enough to understand what its doing.
Can anyone help me understand this?
ParmType is a Integer (0-INT, 1-BOOL, 2-REAL, 3-STRING, 4-LIST) ConfigWord is a Integer
ParmTyp is currently 2 and ConfigWord is 21634 and the label is NOT Visible
if ({#4\ParmType}==2) AND ({#4\ConfigWord} & 8192) then
1
else
0
Doesn't look like anything is wrong with your expression, just that {Root Container.Parm0.ConfigWord} is either not resolving or is resolving to a null value. Make sure you've got a value set for that parameter and that there's no typos.
Every time you see an expression using a pattern like if boolean = true, true, false, there are 2 things you can simplify.
First, comparing a boolean to true is not needed. All it does is make the same boolean out of a boolean.
You're not doing it there, but I see it often enough, and it's related (basically the same thing actually) to the next point,
you don't need to return true or false after evaluating a boolean. The boolean is itself true or false, you can just return it directly. No need to involve another layer there.
Another thing I would suggest, is using hexadecimal format in bitwise operations. It's easier to read - IMO.
I have no idea what 8192 is. But 0x2000 is super easy to decompose:
each character corresponds to 4 bits, so you can already see the 12 first (rightmost) bits are 0.
You only need to deal with the 2, which is 0010.
Easy to see what bit is on in 0x2000.