Programmer Guide/Command Reference/IF: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
END | END | ||
Note that only <code>IF</code> clause mandatory, all other clauses are optional | Note that only the <code>IF</code> clause is mandatory, all other clauses are optional. 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]]. | ||
Neither the [[Programmer_Guide/Concepts/Conditional_Expressions|<var>condition</var>]] nor the <code>singlecommand</code> should contain the string <code>THEN</code>. If either does, in most cases {{STx}} will amazingly mistake the whole command for an ill-formed <code>IF</code> … <code>THEN</code> … <code>END</code> block. | Neither the [[Programmer_Guide/Concepts/Conditional_Expressions|<var>condition</var>]] nor the <code>singlecommand</code> should contain the string <code>THEN</code>. If either does, in most cases {{STx}} will amazingly mistake the whole command for an ill-formed <code>IF</code> … <code>THEN</code> … <code>END</code> block. |
Latest revision as of 15:42, 25 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 … ELSE IF condition2 THEN … ELSE IFNOT conditionn THEN … ELSE … END
Note that only the IF
clause is mandatory, all other clauses are optional. 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.
Neither the condition nor the singlecommand
should contain the string THEN
. If either does, in most cases STx will amazingly mistake the whole command for an ill-formed IF
… THEN
… END
block.