Unable to get simple expression to works

Hi,
I just cannot make this simple formula works : (mode=3?mode=0:mode=mode+1)
mode is a dynamic local variable. I tried with == but it return this error error calculating boolean(false) = integer(0) >> (boolean)null
it was working in ST but seems not after HE migration... Does anyone see something wrong?

Thanks!

It would have to be == to do a comparison.

If you are wanting to assign 0 to mode if mode is 3, otherwise increment it, this is what you want:

mode = mode == 3 ? 0 : mode + 1

yes, but not working! the value always have been incremented so its now 11, but when I enter your formula, it gives 111 so it looks like it just append 1 at the end... pretty strange!
Thanks!

Sounds like your mode is a String then?

its dynamic, I ll look at it again but I also tried with quotes and not working... for now this works to increment but not the if == part ... (mode==3?0:sum(mode,1))

What does this mean. If it's not a number, you can't do math to it.

How about this:

mode = mode.toInteger() == 3 ? 0 : mode.toInteger() + 1

To tell what is going on, add some log.debug, such as

log.debug "mode=$mode, test=${mode.toInteger() == 3}"

I mean that the value got increased by the formula.. it’s now 11 because didn’t reset to 0. The first part of the formula does not work!

Without logging it's not possible for anyone else to know what's going on.

I ll try to supply log and your formula! I had tried with number(3) but not working…

I ll come back later
Thanks

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.