More than one FOR...NEXT loops can be included within another. These are called nested

loops:

10 MODE 7

20 PR0Ctables

30 END

40 DEFPR0Ctables

50 FOR table=1 TO 12

60 PRINT''TAB(8)"The ";table;" times table"''''

70 FOR count=l TO 10

80 PRINT count;" times " ;table; " is "; count*table

90 NEXT count

100 PR0Cinput

110 NEXT table

120 ENDPROC

130 DEFPR0Cinput

140 PRINT''''"Press any key when you're ready for"

150 PRINT' TAB(2)"the next multiplication table"

160 key=GET

170 CLS

180 ENDPROC

The main loop running from line 50 to 110 counts through the multiplication

tables from 1 to 12. The other loop from 70 to 90 nests completely within the

main loop. It multiplies the value of table by all the numbers from I to 10.

The effect of LIST may be altered so that it automatically produces

indentations for every FOR and NEXT pair (and certain other structures).

Type:

LISTO 7 RETURN

LIST RETURN

Notice that the start and end of the loops are in line vertically. This makes it

easier to pick out the loops and spot errors.

Delete line 90, which contains a NEXT, and LIST the program again. The start

and finish of the loop at lines 50 and 110 no longer line up. This is a sure sign

that a loop somewhere in the program is missing a FOR or NEXT.

The option provided by LISTO remains in force until you reset it (using LISTO

0), execute a hard break or switch the computer off. However, leave it in force

for the next section.

REPEAT ... UNTIL

C 39