paragraph.if
conditional branch statement in a paragraph
Syntax
if {'|'}string1{'|'} [<|l|=|e|>|g] {'|'}string2{'|'} then go label
Description
conditional branch statement in a paragraph
The if statement compares the two string operators. If they are both numeric, then they are compared numerically. If either or both cannot be converted to a number, then they are compared alphabetically.
Between the two strings is a single-character conditional operator which may be one of the following:
<,l Less Than
=,e Equal To
>,g Greater than
If the condition evaluates to true, then the paragraph processor starts searching from the beginning of the paragraph for a label which matches the one after the 'go' statement, but which must be followed by a colon and a space. When this label is found, execution of the paragraph continues on the line containing the label.
One of the string parameters in an if statement is usually an input substitution.
Example
if <<Input a number between 1 and 10:>> > 5 then go greater
display Less than or equal to 5
if 1 = 1 then go done
greater: display Greater than 5
done: * There must be a space after the colon
This example asks the user for a number, and then prints a result based on the
value of this number. Note how the 'if' statement is used on the
third line to implement an unconditional branch.
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
