Frequently Asked Question
How do I use arrays in BASIC?
Son yenilənmə 8 days ago
Working with Arrays in Commodore BASIC
Arrays let you store multiple values under one variable name. Essential for games and data processing!
Declaring Arrays with DIM
10 DIM A(10) : REM NUMERIC ARRAY, 11 ELEMENTS (0-10) 20 DIM N$(25) : REM STRING ARRAY, 26 ELEMENTS 30 DIM GRID(10,10) : REM TWO-DIMENSIONAL ARRAY
Filling an Array
10 DIM SCORES(5) 20 FOR I = 0 TO 5 30 READ SCORES(I) 40 NEXT I 50 DATA 1000, 2500, 3200, 4100, 5000, 6500
Searching an Array
100 INPUT "SEARCH FOR"; S 110 FOR I = 0 TO 10 120 IF A(I) = S THEN PRINT "FOUND AT POSITION"; I: GOTO 150 130 NEXT I 140 PRINT "NOT FOUND" 150 END
Memory Considerations
- Arrays use memory! A DIM A(1000) uses significant RAM
- String arrays use even more memory
- Place DIM statements at the start of your program
Tip: Use arrays for high score tables, inventory systems, map data, and any collection of related values.