Programming 695
If...Then...EndIf structures
To execute one group of commands if a conditional test is true, use the
structure:
À Executed only if x>5.
Á Displays the value of:
2x if x>5
x if x{5
Note: EndIf marks the end of the Then block that is executed if the
condition is true.
If...Then...Else...EndIf structures
To execute one group of commands if a conditional test is true and a
different group if the condition is false, use this structure:
À Executed only if x>5.
Á Executed only if x{5.
 Displays value of:
2x if x>5
5x if x{5
If...Then...ElseIf... EndIf structures
A more complex form of the If command lets you test for multiple
conditions. Suppose you want a program to test a user-supplied
argument that signifies one of four options.
If x>5 Then
Disp "x is greater than 5"
À
2
¦x&x À
EndIf
Disp x
Á
If x>5 Then
Disp "x is greater than 5"
À
2
¦x&x À
Else
Disp "x is less than or equal to 5"
Á
5
¦x&x Á
EndIf
Disp x
Â