Purpose : Controls program flow based on the results of a comparison.
. . . . .
Notes: The IF statement allows the execution
of a group of one or more statements when expression is true.
When the comparison is false, a program control jump is made
to the script line following the appropriate ENDIF statement.
Six comparisons are possible. They are as follows:
|a = b||expression is true if a is the same as b|
|a < b||expression is true if a is less than b|
|a > b||expression is true if a is more than b|
|a ! b||expression is true if a is not the same as b|
|a <= b||expression is true if a is less than or equal to b|
|a >= b||expression is true if a is more than or equal to b|
IF...ENDIF statements may be nested to 10 levels. Ensure that the proper combination of IF...ENDIF statements exists. Failure to do so may produce unpredictable results.
# Various IF statement
input weight " Enter your weight: "
input height " Enter your height: "
a = weight / height
waist = a * 1.18
print " Your projected waist size is " waist
if waist < 30
print " Try the Children's Clothing Dept. "
if waist > 47
print " Go to Rochester Big and Tall. "
# IF statement nesting example.
if waist >= 29
if waist <= 47
print " We carry your pants size. "
if waist > 33
if waist < 35
print " But we just sold out. "
See Also: LOOP PROCESS