Arithmetric expressions
Posted: Sun Apr 22, 2007 12:10 am
Hello!
I tend to use arithmetric expressions without the = sign. At first I thought when I write it would be the same as But "some_expression" is not necessarily evaluated first and then multiplied with "a" and the result stored in "a".
It is more like I think the help is not exactly describing this. If some_expression is for example "b+c", it will be like "a" is multiplied with "b" and then "c" is added. The result is stored in "a".
The behaviour is better described as:
An expression without equal sign is evaluated in the normal order and the result is stored in the leftmost variable.
Here is some example code:
It this really the wanted behaviour or is it really a bug? Wouldn't it be nice to have a behaviour like for example in C with +=, -=, *=, /= and so on?
Saves you some braces!
--manu
I tend to use arithmetric expressions without the = sign. At first I thought when I write
Code: Select all
a * some_expression
Code: Select all
a=a*(some_expression)
It is more like
Code: Select all
a=a*some_expression
The behaviour is better described as:
An expression without equal sign is evaluated in the normal order and the result is stored in the leftmost variable.
Here is some example code:
Code: Select all
a=7:b=2:c=3
a+b*c
Debug "a="+Str(a)+" b="+Str(b)+" c="+Str(c)
a=7:b=2:c=3
a*b+c
Debug "a="+Str(a)+" b="+Str(b)+" c="+Str(c)
a=7:b=2:c=3
a|b&c
Debug "a="+Str(a)+" b="+Str(b)+" c="+Str(c)
a=7:b=2:c=3
a|(b&c)
Debug "a="+Str(a)+" b="+Str(b)+" c="+Str(c)
Saves you some braces!
--manu