Page 1 of 1
if then else shorthand a?b:c
Posted: 13 Jan 2014 20:17
by Softcore
Is there a way to use a shorthand for if then (no else)....What if I dont want an "else" condition?
I tried simply entering a?b but pffffffff.....lol
Re: if then else shorthand a?b:c
Posted: 15 Jan 2014 05:18
by Macciza
Hi
There are some things the shorthand is suited to and other things it isn't - it not a straight drop in replacement . .
Though depending on what you are wanting to do, (and where?) there are ways to get around it
For example - try an expression x=a?b:x then Monitor x
x only changes if a is true and nothing seems to be returned else wise - does not return 0 ...
It seems to work - maybe the : ref to x just gets seen a false or null and nothing happens
Cheers
MM
Re: if then else shorthand a?b:c
Posted: 15 Jan 2014 08:24
by Softcore
Ahhh see, the most usual case where I've needed the shorthand is when setting a trigger for a custom message
So for example I want a custom message to be triggered by switch1.x only when switch2.x (a second object)
If I use as trigger:
switch2.x?switch1.x:0
then if previously switch1.x was 1, then even if switch2.x==0, we do have a trigger (switch1.x -> 0).