Page 1 of 1
Extensions have boolean logic limitations?
Posted: 24 Jul 2008, 21:05
by Carl Lydon
Hi,
In an extension, if I try something like:
if (x==1 or y==1){
//do something
}
The script won't load. If I get rid of the "or" and do a nested "if" statement, it works fine. Is this a known limitation?
Posted: 25 Jul 2008, 02:22
by BigFIsh
use || instead of or, same with and = &&
Posted: 28 Jul 2008, 17:21
by ptdgames
Also, get into the habit of doing this:
if ( (x==1) || (y==1) ) {
// do something
}
The extra () sets will make sure the compiler behaves exactly the way you want.
Posted: 29 Jul 2008, 10:02
by duncanhall
I would advise the exact opposite of what ptd suggests.
The compiler is more than happy to recognise (x==1 || x==2) as two seperate conditionals, and the added parenthesis just make it harder to spot exactly what is being evaluated. I would only really include the nested parenthesis when you have multiple evaluations in each conditional.
eg:
if (( x > 3 && x < 10 ) || (x > 20 && x < 30))
Thanks
Posted: 29 Jul 2008, 14:15
by Carl Lydon
Thanks for all the advice. The main thing was that my Flash compiler always recognized "and"..."or", but that Smartfox extensions might not. I'll be in the habit now of always using || or &&