Sharp MZ-700 Owner's Manual page 50

Hide thumbs Also See for MZ-700:
Table of Contents

Advertisement

Example
FOR
.
. .
NEXT loops may be nested within other FOR
...
NEXT loops. When
doing this, inner loops must be completely included within
outer
ones. Further,
separate control variables must be used for each loop
.
10
F
OR
X=1
TO
9
20
0..
FOR
Y
=
~
g
30
PRINT
X*Y;
"2
Q)
4
0
NE XT
Y
§
5
0
PRINT
6
0
NE XT
X
70
END
Incorrect example:
[[
FOR
0=1
TO 1
0
FOR
0=K TO
K+S
NEXT 0
X
Different control variables
must be used in each loop.
-
0..
0
0
-
. ...
Q)
......
;:I
0
F
OR
A=1
TO
3
--,
F
OR
8=1
T
O
5
I
F
OR
C=1
T
O 7
l
······
····
··· ······ ····
··
··
·········
I
NEXT c
l
NE
XT
NEXT
8
NEXT
A
j
c.8.A
When loops C, B, and A all end at the
same point as in the example above, one
NEXT statement may be used to indicate
the end of all the loops.
f
FOR
I
=1
TO
1
0
FOR
0=K
TO
K+5
ILNE
XT
L
NEXT 0
X
Loops may not cross one
another.
Note
The syntax of BASIC does not limit the number of levels to which loops may be
nested;
however,
space is required to store return addresses for each
level,
so
the
number of levels is limited by the amount of available free space.
The CLR statement (see page 59) cannot be used within a FOR
...
NEXT loop.
2. 3. 6. 2 GOTO
..
.......
...........
.
.
.
........
.
..
(abbreviated format:
...
G.)
I
Format
I
GOTO Ln
Function
Example
Ln
....
Destination line number
This statement unconditionally transfers program execution to the line number
specified in
Ln.
If Ln is the number of
a
line which contains executable statements
(statements other than REM or DATA statements), execution
resumes with
that
line; otherwise, execution resumes with the first
executable
statement following
line number Ln.
10
N=1
20
PRINT N
30
N=N+1
40 GO
T
O 20
··
··
··· ········
···Transfers program execution to line
20.
50
END
48--------------------------------------------------------------------------

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents