Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

if limit

Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
02-15-2008 16:20
I know the max number of if-else is 24 (1 if and 23 elses), but what about the max number of straight ifs without elses (eg, if(this){that;} if(who){why;} etc)? Empirically, the max number appears to be 42. That's my assumption based on me getting a syntax error after the first equals sign in the 43rd if statement. Does anybody know for sure?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-15-2008 16:42
It's a little more complicated then that. It has to do with the number of entries in the compilers stack. Globals and variables in the function/event contribute to the stack. I've not seen the 42 limit before.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
02-16-2008 01:02
In my case, the variable being tested is the same every time (eg, if(myVar==1){ doThis();}if(myVar==2){doThat();} etc). I did so to get around the 24 if/else limit. Is this bad practice? I need to test against 70 possibilities. My understanding from the wiki is to reach the 23 limit, then use a jump. Sounds clunky, is there a better way?
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
02-16-2008 02:37
Scratch that, my bad, the script is choking on a 'special' character from the Latin-1 character set. Which is very depressing, since the same script is happily reading such characters in an hhtp_response and outputting them to the chat window with no problems at all :(
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
02-16-2008 06:36
A lot of if statements without else will make the script very slow.

It depends on what you want to do. I saw some big scripts with a lot of if that can be replaced by just one, or none :).

This is a silly example, but I saw stuff like:

if (number == 1)
{
llSay(0,"1";);
}
if (number == 2)
{
llSay(0,"2";);
}

-----

So analyze the case and check if you really need all those "If"