![]() | ![]() | |||||||||||||||
| ||||||||||||||||
Flow of ControlThe If Statementif statements are used for conditional branching.
if x > y then
Example: The If Statement
The Case StatementThe case statement can test a variable for several different values.
type country is ( australia, u_k, brazil );
Example: The Case Statement
Multiple cases can be strung together using a vertical bar (|). when brazil | u_k => -- brazil or U.K. The "when" cases must not be variables (although constants are OK). The "when others" case is always required. The While Loop StatementThe while loop is a pre-test loop. The commands in the loop are repeat while the condition is true and the condition is tested each time the first line of the loop is executed.
while x < y loop
Example: The While Statement
The For Loop StatementThe for loop increments its index variable by 1 until it iterates through the specified range. The index variable is automatically declared for you and only exists for the scope of the the loop. The range can either be numeric or enumerated.
for i in 1..10 loop
Example: The For Statement
To loop in reverse in a for loop, use "in reverse" instead of "in". The Exit StatementAny loop can be exited by using either an exit statement or an "exit when" shorthand.
if x > 100 then exit when x > 100;
Example: Examples of the Exit Statement
The Loop Loop StatementA "loop" loop is a general purpose loop. It can only be exited with "exit".
loop
Example: The Loop Statement
|
Block Statements and Subprograms |