DIM arrays can function as a sum-to-memory system found in many calculators. More importantly, it acts as a counter function and can be used where FOR-NEXT loops will not work. Moving Billboard, this page, illustrates the counter function. Here’s a simple demonstration of the sum-to-memory system:
10 DIM B(1)
20 INPUT A
30 PRINT A
40 LET B(1)=B(1)+A
50 IF A=5 THEN PRINT B(1)
60 GOTO 20
Input a few numbers, hitting ENTER after each. Finish with 5 to execute line 50. B(1)’s value will appear and turns out to be the sum of the input numbers. To regain program listing, input any letter (not a number) and hit ENTER twice.
Change line 60 to 60 GOTO 10 and see that the sum-to-memory function is lost. Each time the computer executes a DIM line, all array values are cleared to zero.
Products
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.