Table of Contents
ifDescriptionTest the value of a condition, and if true, execute a statement block. Statement prototypeif <bool:condition> ... statement block ... endif Arguments
Exampleint i set i 5 if <islt i 0> echo "negative number" elseif <iseq i 0> echo "zero" else echo "positive number" endif CommentsTerminating an 'if' statement block
Each 'Else' after 'if'
ZeoScript differs from C/C++ and some other programming languages in that Wrong: if <islt i 0> echo "negative number" else // error, else not terminated by endif if <iseq i 0> echo "zero" else echo "positive number" endif This code will result in the following error: ZeoScript error: Cannot find matching 'endif' for 'else' statement. - Line 3: 'else' ZeoScript compilation aborted on line 3 following errors. Right: if <islt i 0> echo "negative number" else // now the else is terminated by 'endif', and contents are nested if <iseq i 0> echo "zero" else echo "positive number" endif endif Better: if <islt i 0> echo "negative number" elseif <iseq i 0> // using the elseif statement, rather than nested else/if echo "zero" else echo "positive number" endif See alsoExcept where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|