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: