EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 165

Radio Shack TRS-80 Model III
274 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
Loading...
BASIC
ON n
GOSUB line
number, ...,
line
number
Works
like ON n GOTO,
except
control branches to
one
of the subroutines
specified
by
the line numbers
in the line-number
list.
Example:
100
INPUT "CHOOSE
1) 2. OR
3"
5
I
110
ON
I
GOSUB
200*
300* 400
120
END
200 PRINT
"SUBROUTINE
#1":
RETURN
300 PRINT
"SUBROUTINE
#2":
RETURN
400
PRINT
"SUBROUTINE
#3":
RETURN
The test
object
n
may be a
numerical constant,
variable or
expression. It must
have
a
non-negative value or an
error will
occur.
See ON n GOTO.
FOR
counter
=
exp
TO exp
STEP exp
NEXT
counter
Opens an iterative
(repetitive) loop so
that
a
sequence
of program statements
may
be executed over and
over
a
specified
number of times
.
The
general form is
(brackets indicate
optional material):
line # FOR
counter-variable
=
initial value TO
final
value [STEP
increment]
line
#
NEXT
[counter- variable]
In
the FOR statement,
initial value,
final
value
and
increment cm be constants,
variables or expressions .
The first time the
FOR statement is
executed, these three
are
evaluated and the values are
saved; if the
variables are changed
by
the loop, it
will have no effect on the
loop's operation.
However, the counter
variable must
not be
changed or the loop
will
not
operate
normally.
The
FOR-NEXT-STEP loop works as
follows: the
first time the
FOR statement is
executed, the
counter is set to the
"initial value.
'
'
Execution proceeds
until
a
NEXT
statement is encountered. At
this point, the
counter is
incremented
by
the
amount
specified in the STEP increment.
(If the
increment has a
negative value
,
then
the
counter
is actually decremented.)
If STEP
increment is not used,
an increment of
1
is
assumed.
155

Other manuals for Radio Shack TRS-80 Model III

Related product manuals