EasyManuals Logo

IBM 5100 Basic Reference Manual

IBM 5100
187 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #79 background imageLoading...
Page #79 background image
(
(
(
(
GOSUB line-num
[[,Iine-num]
•••
ON
arith~xp
]
RETURN
GOSUB AND RETURN
The GOSUB and RETURN statements are used together
to
create subroutines. The
GOSUB statement transfers control conditionally or unconditionally
to
a specified
statement. The RETURN statement transfers control
to
the first executable state-
ment following the last active GOSUB statement
that
was executed.
The syntax
of
the GOSUB statement
is
either simple
or
computed. The simple
syntax
is:
GOSUB line-num
where:
line-num
is
the number
of
the statement
to
which control
is
to
be transferred.
The computed GOSUB syntax
is:
GOSUB line-num [,Iine-num]
•..
ON
arith~xp
where:
/ine-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.
The format
of
the RETURN statement
is
simply RETURN.
Execution of a simple
GOSUB
statement causes
an
unconditional transfer of con-
trol
to
the statement whose number
is
specified.
Execution
of
a computed GOSUB 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 GOSUB statement.
When
a GOSUB statement transfers control
to
a nonexecutable statement, control
is
transferred
to
the first executable statement following the specified nonexecutable
statement.
Execution
of
a RETURN statement causes an unconditional transfer
of
control
to
the first executable statement following the last active GOSUB statement
that
was
executed.
75

Table of Contents

Other manuals for IBM 5100

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM 5100 and is the answer not in the manual?

IBM 5100 Specifications

General IconGeneral
Release Year1975
RAM16 KB - 64 KB
Storage204 KB tape drive
Display5-inch CRT
Operating SystemAPL/BASIC
ProcessorIBM PALM (1.9 MHz)

Related product manuals