BASIC: string arrays (DIM A$(n), one or two subscripts)
Elements hold up to 79 characters, 80 bytes each, at most 255 per array; undeclared ones get 0..10 like numeric arrays. All string-variable uses now go through one str_ref(), which more than pays for the feature in ROM. The arena gives up 156 bytes for the larger array table so nothing after it moves. Adds basic/test-strarr.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d1be15786
commit
c553824df0
7 files changed
+2269
-2170
No files matched your search
+20
-4
@@ -154,6 +154,21 @@ empty. String constants are written in double quotes. `+` joins strings:
|
||||
30 PRINT B$
|
||||
```
|
||||
|
||||
String arrays work like numeric ones, with a `$` after the letter. Each element
|
||||
holds up to 79 characters and starts empty:
|
||||
|
||||
```
|
||||
10 DIM N$(4)
|
||||
20 FOR I = 0 TO 4: READ N$(I): NEXT I
|
||||
30 PRINT N$(2)
|
||||
40 DATA RED, GREEN, BLUE, YELLOW, WHITE
|
||||
```
|
||||
|
||||
`N$`, `N$( )` and `N( )` are all separate. A string array used without `DIM`
|
||||
gets subscripts 0 to 10. Every element takes 80 bytes whether it is used or
|
||||
not, so a string array can have at most 255 elements, and `DIM A$(200)` uses
|
||||
about 16 KB of the program space.
|
||||
|
||||
## 4. Expressions
|
||||
|
||||
From highest precedence to lowest:
|
||||
@@ -281,10 +296,11 @@ NEXT J, I
|
||||
### DIM — arrays
|
||||
|
||||
```
|
||||
DIM A(50), B(10,20)
|
||||
DIM A(50), B(10,20), N$(30)
|
||||
```
|
||||
|
||||
See section 3. An array can hold at most 6000 elements.
|
||||
See section 3. A numeric array can hold at most 6000 elements, a string array
|
||||
255.
|
||||
|
||||
### DEF FN — your own functions
|
||||
|
||||
@@ -1323,11 +1339,11 @@ while keeping the cave connected, mirrored and free of dead ends
|
||||
|
||||
| Item | Limit |
|
||||
|---|---|
|
||||
| Program and arrays together | about 20.3 KB |
|
||||
| Program and arrays together | about 20.2 KB |
|
||||
| Line numbers | 0 – 65535 |
|
||||
| Line length | 250 characters typed |
|
||||
| Numeric variables | A–Z and A0–Z9 |
|
||||
| String variables | A$–Z$, 79 characters each |
|
||||
| String variables | A$–Z$, 79 characters each; string arrays A$( )–Z$( ), up to 255 elements |
|
||||
| Arrays | A–Z, 1 or 2 subscripts, up to 6000 elements each |
|
||||
| User functions | FNA–FNZ, one argument each |
|
||||
| FOR nesting / GOSUB nesting | 16 / 32 |
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user