IBM 5100 Basic Reference Manual page 82

Hide thumbs Also See for 5100:
Table of Contents

Advertisement

IF
78
{ arlth-ex
p rel-opr arith-exp }[{&},rith-ex p rel-opr arith-exp
l..l
{THEN }Iine-num
char-exp rel-opr char-exp
I
r=har-ex p rel-opr char-exp
fJ
GOTO
IF
The I F statement allows you to transfer program control according to the result of
an evaluated expression. The syntax of the IF statement is as shown:
IF
{ arith-ex
p rel-opr arith-exp }[{&},rith-ex p rel-opr arith-exp
11
{THEN }Iine-num
char-exp rel-opr char-exp
I
r=har-ex p rel-opr char-exp
fJ
GOTO
where:
arith-exp and char-exp are arithmetic or character expressions or a string function.
Only one pair of expressions is required.
rel-opr is a relational operator. Only one operator is required.
& is the symbol entered for AND.
I
is the symbol entered for OR.
THEN
and
GOTO
specify that control should be transferred. If you enter THEN,
each time the program is listed on the display screen or printer, the system sub-
stitutes GOTO for THEN.
line-num is the number of the statement to which control is transferred if the
relational expression(s) is true.
When an I F statement is executed, the expressions are compared as specified by
the relational operator. If the relationship is true, control is transferred to the
specified statement number. If the relationship is not true, control is passed to
the first executable statement following the I F statement.
Before being compared, a character constant containing less than 18 characters is
padded on the right with blanks to a length of 18. A character constant containing
more than 18 characters is truncated on the right to a length of 18 before com-
parison. A character constant containing no characters (null) is compared as 18
blank characters.
If & is specified, both relational expressions must be true before control passes to
the statement number.
If
I
is specified, control passes to the specified line number
if either relational expression is true.
If the specified relationship is true and the specified statement is nonexecutable,
control is passed to the first executable statement following the specified nonexe-
cutable statement.
/
/
I

Advertisement

Table of Contents
loading

Table of Contents