English
Language : 

NSB8 Datasheet, PDF (105/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
Example #8
10 REM Assume a 10 elements array A.
20 REM The following searches A from element 1 to 10 for the first non zero element.
30 REM The index of this element will be N.
40 REM If all elements are 0, N will also be 0.
50 REM A FOR loop is used for the scan,and EXIT stops scan if non zero found.
80 FOR N=1 TO 10
90 IF A(N) <>0 THEN EXIT 130
110 NEXT
120 N=0 \ REM By this point, A is all zeroes.
130 REM By this point, N contains correct index or zero.
EXITING FROM NESTED LOOPS
Several nested loops may all be terminated prematurely at once using EXIT, but a separate EXIT
statement must be used for each embedded loop. For example, if execution is proceeding at line 30
in the inner loop of a two deep nest (example #6), and it is desired to go to line 600, outside the
outermost loop, the following example represents an efficient method of doing so using the EXIT
statement:
Example #9
10 FOR I=0 TO 9
20 FOR J=0 TO 9
30 PRINT I, J
35 EXIT 45
40 NEXT
45 EXIT 600
50 NEXT
SEE ALSO:
Statement FOR
Statement NEXT
Statement EXIT
NSB8
Rel. 5.10
Page 93