Author Topic: Multidimensional arrays  (Read 1689 times)

Offline Elemee

  • Mc. Print
  • *
  • Posts: 4
    • View Profile
Multidimensional arrays
« on: 2015-Dec-01 »
I'm new to GLB and trying to convert a game I wrote in another Basic dialect which uses a 6 dimensional array as a primary data structure.  It appears there is a 4 dimension limit in GL Basic.  I thought of using Types to address this and was wondering if multidimensional arrays can be handled as variables in a Type, and what the limits are regarding associating chains of variables with Types.  I'm a complete novice so if someone can point me in the right direction to learn about this (other than just trial and error) I'd appreciate it.     

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10739
  • here on my island the sea says 'hello'
    • View Profile
Re: Multidimensional arrays
« Reply #1 on: 2015-Dec-04 »
Type A
Stuff []
Tyoe B
evenmorestuff [] as A

Offline sf-in-sf

  • Mr. Drawsprite
  • **
  • Posts: 93
  • Artist F.P. Brixey
    • View Profile
    • My computed art project
Re: Multidimensional arrays
« Reply #2 on: 2015-Dec-05 »
Multidimensional arrays? You could switch to C inline code to use them as such. Otherwise, you can use a monodimensional array, and compute which cell/address you want to access. It's the same... remember that all the memory is linear, and accessed like that in a linear way, the data addresses.
Example: GLOBAL v%[] // confusing, I know.   DIM v%[10][20][30][40]
"v[w][X][y][z]" is nothing more than v[40*30*20*w + 40*30*X + 40*y + z]     (from memory lane, please check it.)
This way the number of dimensions in unlimited -just the total RAM size is.
On the day the atom is a cube I will start believing in the square pixel.