January 21, 2021, 04:57:30 AM

#### JBR

• Full Member
• Posts: 123
##### Didn't know this about arrays
« on: April 23, 2020, 01:30:12 AM »

I have it declared as Global A_Jim[1024,2]

But it accepts A_Jim[23] = 999, say.

It puts the 999 in [23,1]

Took me a while to figure out as I expected it to throw an error but it does not.

Jim.

#### JBR

• Full Member
• Posts: 123
##### Re: Didn't know this about arrays
« Reply #1 on: April 23, 2020, 11:43:37 PM »

I have it declared as Global A_Jim[1024,2]

But it accepts A_Jim[23] = 999, say.

It puts the 999 in [23,1]

Took me a while to figure out as I expected it to throw an error but it does not.

Jim.

Correction it puts 999 in [11,1]

i.e. 11*2 + 1

#### _PJ_

• Jr. Member
• Posts: 96
##### Re: Didn't know this about arrays
« Reply #2 on: July 21, 2020, 01:52:05 PM »
A_Array[Z] = 999

It should fill the Zth "position" with a value of 999 as the data values are stored in memory in linear taking the dimensions of the array in rows then columns then layers etc.

For example:

A_Array:Int[] = New Int[X,Y,Z]

A_Array[(X * Y * Z) -1] = "1"
Will always set the last position to '1'

For Local Iter:Int = 0 Until Y
a[ Iter * (X-1) ]=1 Next
Would set the last entry in each column of the first layer's values to '1' as these positions in array are regularly spaced throughout the linear data by intervals of X

_

Personally, if opting for this method of data manipulation, I prefer to work with BANKS since it is essentially the same process, but may be faster.