Goto - IBM 5100 Basic Reference Manual

Hide thumbs Also See for 5100:
Table of Contents

Advertisement

(
(
(
(
(
GOTO line-num [Lline-numl ... ON arith-exp ]
GOTO
The GOTO statement transfers control either conditionally or unconditionally to a
specified statement.
The syntax of the GOTO statement can be simple or computed. The simple syntax
is:
GOTO line-num
where:
line-num is the number of the statement to which control is to be transferred.
The computed GOTO syntax is:
GOTO line-num [,Iine-numl •.. ON arith-exp
where:
line-num is a string of statement numbers separated by commas. At least one
statement number is required.
arith-exp determines the statement to which control is passed.
Execution of a simple GOTO statement causes an unconditional transfer of control
to the statement number specified.
Execution of a computed GOTO statement causes the arithmetic expression to be
evaluated and control transferred to the statement whose numeric position in the
list of statement numbers (reading left to right) is equal to the truncated integer
value of the expression. Thus, an expression with a value of 2.75 would cause con-
trol to be transferred to the second statement in the list. If the expression has a
value less than 1 or greater than the total number of statements listed, control falls
through to the first executable statement following the computed GOTO
statement.
When a simple or computed GbTO statement transfers control to a nonexecutable
statement, control is then passed to the first executable statement following the
specified nonexecutable statement.
The following statement will unconditionally pass control to statement number
20:
100 GOTO 20
If
X
=
4, the following statement will pass control to statement number 60:
50 GOTO 40, 60, 15, 100 ON (X+4)/4
77

Advertisement

Table of Contents
loading

Table of Contents