IF: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{missing}}
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.
 
See also [[conditional modelling]], [[SWITCH]], [[WHEN]] and [[SELECT]].
 
[[Category:Syntax]]
[[Category:Syntax]]

Latest revision as of 08:05, 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 and SELECT.