A Patch For Double Loops

By Bob Huelsdonk

When inputting to a double loop by row, then jumping out to a double loop to total by column, it is necessary to revers the subscript order.

This will not work in Applesoft BASIC because the right counters do not reset.  The following simple example will demonstrate:

80 PRINT¬† “INPUT ‘-1’ TO TERMINATE INPUTS”
100 FOR R = 1 TO 3
120 FOR C = 1 TO 3
140 INPUT A(R,C)
160 IF A(R,C) = – 1 THEN 300
180 NEXT C
200 NEXT R
300 FOR C = 1 TO 3
320 FOR R = 1 TO 3
340 PRINT A(R,C)
360 NEXT R
380 NEXT C

If the following changes are made, this problem is overcome:

160 IF A(R,C)=-1 THEN 250
250 FOR R=0 TO 0 : NEXT R

The empty ‘R’ loop resets the counter.

Please follow and like us:

About the Author

billm

A.P.P.L.E. Chairman of the Board and Club president — Bill worked for the founder, Val J. Golding and A.P.P.L.E. from 1981 to 1982. In 1999, he began archiving the materials which were distributed and sold by A.P.P.L.E.. That project led to the group that remained of A.P.P.L.E. Bill was involved in the financial industry in Tokyo and has over 20 major office infrastructure projects to his name. In March 2001, he retired to write books and to spend more time pursuing personal interests. As the president of the users group, Bill is in charge of distribution of Call-A.P.P.L.E. magazine as well as the organization of this web site. Bill currently resides in Tokyo, Japan and Shelton, Wa splitting time between the places.