Programmer Guide/Command Reference/IF: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition]]</var> singlecommand | IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition]]</var> singlecommand | ||
IFNOT <var>condition</var> singlecommand | IFNOT <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition]]</var> singlecommand | ||
The second allows conditional execution of multiple commands within a block: | The second allows conditional execution of multiple commands within a block: | ||
IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>1</sub>]]</var> THEN | IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>1</sub>]]</var> THEN | ||
&hellip: | |||
ELSE IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>2</sub>]]</var> THEN | ELSE IF <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>2</sub>]]</var> THEN | ||
&hellip: | |||
ELSE IFNOT <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>n</sub>]]</var> THEN | ELSE IFNOT <var>[[Programmer_Guide/Concepts/Conditional_Expressions|condition<sub>n</sub>]]</var> THEN | ||
&hellip: | |||
ELSE | ELSE | ||
&hellip: | |||
END | END | ||
Note that only <code>IF</code> clause mandatory, all other clauses are optional. Both command forms <code>IF</code> and <code>IFNOT</code> can be used. Empty clauses (i.e., clauses without commands) are allowed. The last clause must be closed with an <code>[[Programmer Guide/Command Reference/END|END]]</code> statement. For more information on conditions see [[Programmer_Guide/Concepts/Conditional_Expressions|Conditional Expressions]]. | Note that only <code>IF</code> clause mandatory, all other clauses are optional. Both command forms <code>IF</code> and <code>IFNOT</code> can be used. Empty clauses (i.e., clauses without commands) are allowed. The last clause must be closed with an <code>[[Programmer Guide/Command Reference/END|END]]</code> statement. For more information on conditions see [[Programmer_Guide/Concepts/Conditional_Expressions|Conditional Expressions]]. |
Revision as of 15:52, 15 April 2014
There are two forms of the IF
syntax. The first allows the conditional execution of one command:
IF condition singlecommand IFNOT condition singlecommand
The second allows conditional execution of multiple commands within a block:
IF condition1 THEN &hellip: ELSE IF condition2 THEN &hellip: ELSE IFNOT conditionn THEN &hellip: ELSE &hellip: END
Note that only IF
clause mandatory, all other clauses are optional. Both command forms IF
and IFNOT
can be used. Empty clauses (i.e., clauses without commands) are allowed. The last clause must be closed with an END
statement. For more information on conditions see Conditional Expressions.