Branch Statements; Definition Statements - Sharp MZ-80A Owner's Manual

Hide thumbs Also See for MZ-80A:
Table of Contents

Advertisement

110
1.5.5 Branch
statements
GOTO
100 GOTO 200
Jumps
to
the statement on line number
200.
GOSUB
100
GOSUB
700
Calls the subroutine starting on line number
700.
At the end of
~
RETURN
800
RETURN
subroutine,
program
execution returns to
the
statement
following
the
corresponding
GOSUB
statement.
IF
~
THEN
10 IF A>20 THEN 200
Jumps to
the statement
on
line number
200 when the value of
variable
A is
more than 20: otherwise
the next line is
executed.
50 IF B<3 THEN B=B+3
Substitutes
B+3
into variable
B when
the
value of B
is less than
3;
otherwise the next line is executed.
IF
~
GOTO
100 IF A>=B THEN 10
Jumps
to
the statement
on line number 10 when
the value
of
vari¬
able
A is equal to
or
greater
than the value
of
B;
otherwise the next
line is executed.
IF
-
GOSUB
30 IF A=B*2 GOSUB 90
Jumps
to
the subroutine
starling
on
line number 700 when the
value of variable A
is
twice the value of
B;
otherwise the next state¬
ment is
executed.
(When
other statements follow a conditional statement
on the
same
line
and
the conditions
are
not satisfied,
those following an
ON
statement
are
executed sequentially, but those following an
IF
statement
are
ignored
and the
statement
on the
next
line
is
exe¬
cuted.)
ON
~
GOTO
50 ON
A
GOTO
70. 80.
90
Jumps
to
the
statement
on
line number
70
when the value
of varia¬
ble
A is 1
.
to the
statement
on
line number 80 when it is 2 and
to
the statement
on
line number
90
when it is
3. When the value of
A
is
0 or more
than 3, the next statement is
executed. This
statement
has the
same
function as the INT function, so that when
the value
of
A is 2.7,
program
execution jumps
to
the statement
on
line
number
80.
ON
~
GOSUB
90
ON
A
GOSUB
700,
800
Jumps
to the subroutine
on
line number 700 when the value of
variable A is 1 and jumps to the subroutine on line number
800
when
it is
2.
1.5.6 Definition
statements
DIM
When an array is
used,
the number of array elements
must
be de¬
clared with
a DIM statement. The number of elements
ranges from
0
to
255.
10 DIM
A(20)
Declares
that
21 array elements.
A(0)
through
A(20).
are
used for
one-dimensional numeric array A(n).

Advertisement

Table of Contents
loading

Table of Contents