Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D Array Errors
#1
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:

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
Reply


Messages In This Thread
2D Array Errors - by raymondlesley - 02-13-2025, 03:42 PM
RE: 2D Array Errors - by boriel - 02-16-2025, 04:05 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)