IF: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
The '''IF''' statement is used to define conditional procedural code, and can only appear in a [[METHOD]] definition. Its syntax is | |||
<source lang=a4c> | |||
IF logical_expression THEN | |||
list_of_statements | |||
ELSE | |||
list_of_statements | |||
END IF; | |||
</source> | |||
or | |||
<source lang=a4c> | |||
IF logical_expression THEN | |||
list_of_statements | |||
END IF; | |||
</source> | |||
If the logical expression has a value of TRUE, ASCEND will execute the statements in the THEN part. If the value is FALSE, ASCEND executes the state- | |||
ments in the optional ELSE part. It's a good idea to use () to make the precedence of AND, OR, NOT, ==, and != clear to both the user and the system. | |||
[[Category:Syntax]] | [[Category:Syntax]] | ||
Revision as of 08:03, 15 August 2010
The IF statement is used to define conditional procedural code, and can only appear in a METHOD definition. Its syntax is
IF logical_expression THEN list_of_statements ELSE list_of_statements END IF;
or
IF logical_expression THEN list_of_statements END IF;
If the logical expression has a value of TRUE, ASCEND will execute the statements in the THEN part. If the value is FALSE, ASCEND executes the state- ments in the optional ELSE part. It's a good idea to use () to make the precedence of AND, OR, NOT, ==, and != clear to both the user and the system.