[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
IF/THEN/ELSE Conditional Testing pp 57
Define: Conditional execution dependent upon a Boolean condition.
Purpose: Allow execution of statements or blocks of statements depending
upon the results of a Boolean test condition.
Notes: The If statement specifies that a statement be executed only
if a certain condition is True. If False, then either no
statement or the statement following the reserved word Else
is executed.
Else must not be followed by a semi-colon.
The Else clause generally belongs to the last If
statement which has no Else part.
----------------------------------------------------------------------------
Usage:
BEGIN
If 1 < 2 Then WriteLn ('1'); { Execute because 1 < 2 is True }
If (1+1) < (2+2) { Execute because 2 < 4 is True }
Then Begin { Start of compound statements }
WriteLn ('OK'); { Executed because 2 < 4 is True }
End { Note there is no semi-colon }
Else { Execute only if 2 < 4 is False }
WriteLn ('Not OK'); { This would execute instead of OK }
END.
See Also:
Case
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson