EasyManua.ls Logo

Sharp MZ-700 - Page 50

Sharp MZ-700
213 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...
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
FOR 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
FOR
A=1
TO
3
--,
FOR
8=1
TO
5
I
FOR
C
=1
TO 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
ILN
EXT
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
TO
20
··
··
············
··
Transfers program execution
to
line 20.
50
END
48----
----
------------------------------
------------------
------
------------

Other manuals for Sharp MZ-700

Related product manuals