2D arrays?
Hi.
Im in a need for a 2D array, but i cant find anyway to create one.
Does the SPIN language not support arrays larger than one dimension?
Im in a need for a 2D array, but i cant find anyway to create one.
Does the SPIN language not support arrays larger than one dimension?

Comments
Let's say that you have a 2 dimensional array of data NM, where N is the number of columns and M is the number of rows which you wanted to store in a 1 dimensional array... and you have the base address of your 1 dimensional array.... data that you want to put into i,j would place at
address (i,j)=base address+ i + j*N.
address (i,j,k)= base address + i + j*N + k*N*M
VAR LONG myArray[noparse][[/noparse] 2] '2D array with 2 rows and 10 columns BYTE myArray0[noparse][[/noparse]10] 'first row with 10 columns BYTE myArray1[noparse][[/noparse]10] 'second row with 10 columns PUB initArray | i, j 'initialize memory pointer for rows LONG[noparse][[/noparse]@myArray][noparse][[/noparse] 0] := @myArray0 LONG[noparse][[/noparse]@myArray][noparse][[/noparse] 1] := @myArray1 'example how to access the 2D array repeat i from 0 to 1 repeat j from 0 to 9 BYTE[noparse][[/noparse]LONG[noparse][[/noparse]@myArray][noparse][[/noparse] i]][noparse][[/noparse] j] := 0The LONG array is used to store the memory pointer of the arrays used for the rows. For performance reason it is recommendable to use the lesser size of dimension for the rows.
The BYTE arrays stores the data, this could be also WORD or LONG.
It is possible to use this for more dimensions, but I think it could be to complicated and not readable.