Malavok Posted June 4, 2009 Share Posted June 4, 2009 Conserning correct placement of else/if in a script (I'm a noob), I'd like to know if this is the correct way to place if and else (I'm thinking that the second subscript should be something more, or that it should be placed within the "else" tag)?: If [subscript1]If [subscript2]Else [subscript3]EndifEndif Link to comment Share on other sites More sharing options...
mazakala Posted June 4, 2009 Share Posted June 4, 2009 Two conditions and an else: if[subscript1]elseif[subscript2]Else[subscript3]Endif You can list as many elseifs as you want, and you only need one endif. If you nest the ifs you'll need a corresponding number of endifs if [subscript1]elseif [subscript2]else[subscript3]endifendif Link to comment Share on other sites More sharing options...
Malavok Posted June 4, 2009 Author Share Posted June 4, 2009 Ok, thanks. I remember seeing something like "elseif", but I wasn't sure. :rolleyes: Link to comment Share on other sites More sharing options...
Alundaio Posted June 5, 2009 Share Posted June 5, 2009 If(subscript) If(subscript) EndIf ElseIf(subscript) EndIf ;---------------------------------- ;You can do stuff like this too ;----------------------------------- If(subscript && subscript) || (subscript && subscript) If(subscript || (subscript && subscript)) EndIf EndIf Make sure you indent your Code. Add comments if you write alot. It's easy to get lost in code in the GECK. Link to comment Share on other sites More sharing options...
TGBlank Posted June 5, 2009 Share Posted June 5, 2009 Please use proper indenting. It helps understanding code. Proper forms should be this: If (Condition) [Stuff] EndIf this:If (Condition) [Stuff] Else [Stuff2] EndIf This:If (Condition) [Stuff] ElseIf (Condition2) [Stuff2] EndIf And This:If (Condition) [Stuff] ElseIf (Condition2) [Stuff2] Else [Stuff3] EndIf Which can be expanded indefinitely like this: If (Condition) [Stuff] ElseIf (Condition2) [Stuff2] ElseIf (Condition3) [Stuff3] ElseIf (Condition4) [Stuff4] ElseIf (Condition5) [Stuff5] ElseIf (Condition6) [Stuff6] ElseIf (Condition7) [Stuff7] ElseIf (Condition8) [Stuff8] ElseIf (Condition9) [Stuff9] Else [Stuff10] EndIf Nesting is also valid: If (Condition1) [Stuff] If (Condition2) [Other Stuff] Else [More Stuff] If (Condition3) Else [Even More Stuff] EndIf EndIf EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.