IF: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
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-
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.
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.
See also [[conditional modelling]], [[SWITCH]], [[WHEN]].


[[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.

See also conditional modelling, SWITCH, WHEN.