02-13-2025, 03:42 PM
I've been enjoying using ZX BASIC so far. It's great to have something that's easy to use (and in-keeping with the original Sinclair BASIC). I have come up against an issue which I can't find a solution for:
The compiler supports multi-dimensional arrays, but it throws an error if I attempt to get a "slice" of the data.
My code:
I get no errors relating to element12
I would expect that element0 should result in {0, 1, 2, 3}. It's the right "shape". Instead I get an error:
I've tried variants e.g. data_array(0, : ) or data_array(0,0 TO 3). Nothing seems to work.
I'm using ZX BASIC 1.17.2
The compiler supports multi-dimensional arrays, but it throws an error if I attempt to get a "slice" of the data.
My code:
Code:
DIM data_array(0 TO 2, 0 TO 3) AS UByte = { _
{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11} _
}
DIM element12 AS UByte = data_array(1, 2)
DIM element0(0 TO 3) AS UByte
element0 = data_array(0) ' throws an error
I get no errors relating to element12
I would expect that element0 should result in {0, 1, 2, 3}. It's the right "shape". Instead I get an error:
Quote:
array_test.bas:9: error: Syntax Error. Unexpected token '(' <LP>
I've tried variants e.g. data_array(0, : ) or data_array(0,0 TO 3). Nothing seems to work.
I'm using ZX BASIC 1.17.2