English
Language : 

NSB8 Datasheet, PDF (56/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
NEXT
grifo®
ITALIAN TECHNOLOGY
STATEMENT:
NEXT
NEXT <numeric variable>
ACTION:
Terminates execution of the loop which starts with the matching FOR statement. For a complete
description of this loop, see section FOR NEXT LOOP.
If the optional numeric variable name is specified as part of the NEXT statement, a check is made
to match that variable name against the control variable specified in the corresponding FOR
statement.
EXAMPLES:
NEXT
NEXT Q
NEXT A(1)
REMARKS:
It should be noted that the check variable in the NEXT statement, while optional in NSB8, is required
in almost every other dialect of the BASIC language. The use of NEXT without the check variable
can speed program execution.
Upon normal completion of a FOR NEXT loop, the control variable will contain the first value that
exceeds the limit. To illustrate, here is an example program:
10 FOR K=1 TO 5 STEP 2
20 NEXT K
30 PRINT K
When RUN, the above generates the following output:
7
Note that NEXT should not be used as the THEN or ELSE part of an IF statement.
ERROR MESSAGES:
CONTROL STACK ERROR
An attempt was made to execute a NEXT statement with no FOR loop in effect. Also, this error
occurs when the variable specified in the NEXT statement doesn’t match the control variable
specified in the previous FOR statement. This usually means that loops are improperly nested.
SEE ALSO:
Statement FOR
Section FOR NEXT LOOP
Page 44
NSB8
Rel. 5.10