2D arrays?
lassethomsen
Posts: 46
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
The 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.