The comparison operators works as they should, but there are a few rules
to this as well.
<=, >=, < and >
The values on either side will be converted to numbers (temporary during
the comparison). If any of the values cannot be converted (i.e. a text or
a poorly formated number) it will become 0.
Example ('a' < 1) is true as 'a' is equal to 0.
Please note that == and != is purely string conversations; this means that
0 == 00 is false, 'a' == 0 is false and 1 == 1 is true.
Good programming practice is to enclose the comparison operators in ''s, as
this is a requirement in order to use <= and >=.
I.e.: a '<=' 1
The above rules that applies for ## is applied here as well.
Another good one is that && and || should have their left and right sides
contained within blocks. But that's ofcourse up to the modder =)
Also remember, no ( ) blocks, or comparisons, at the left side of the &&
or || operators. *UPDATED*
(1 == 1) && (2 == 2)
IS NOT VALID
A note about XML:
Since the &-character is special in XML, doing '&&' will probably just hang
your client. Instead, replace '&&' with '&&'
This should do the trick!
Now to the conditional operators '?' and ':';
Each side on both of the operators must contain real values (or variables),
no special characters, operators or blocks.
(1 == 1) ? yes : no
The above example will not work, as left side of ? contains a block.
So how do we compare? Simple workaround.
Code:
COND ? yes : no COND = (1 == 1)
------------
A side note:
The UI scripting engine interprets the text from top to bottom, and from
right to left; examples below:
COND is set first, then LocalText:
Code:
COND=1
LocalText=COND
Same here, COND is set.. then LocalText:
Code:
LocalText=COND COND=1
------------
Assign (1 == 1) to COND, and use COND as the condition for ? :
And if we want to have some more complicated things to do, we'll
have to put them outside of the condition segment...
Code:
COND = MyGender == male
BROTHER = 'Welcome brother ' ## MyName
SISTER = 'Welcome sister ' ## MyName
LocalText = COND ? BROTHER : SISTER
Please note this:
If the condition is TRUE - no further text can be appended to the resulting
value, but this doesn't prevent processing through.
Code:
LocalText = (X ? 'Cool' : 'Very' ) ## ' funny'
The above is a good example of this; if X is TRUE, LocalText will be set
to 'Cool' .. ignoring the text after the ( ? : ) block.
If X is FALSE, LocalText becomes 'Very' and ' funny' is appended to the
string.
-
If you have any more questions, please ask =)
Daniel