### Author Topic: Dynamic multidimensional array?  (Read 157 times)

#### JohnnyB

• Mc. Print
• Posts: 25
##### Dynamic multidimensional array?
« on: 2019-Aug-21 »
is this possible?

dim x[44][]

does not work, e.g.

#### JohnnyB

• Mc. Print
• Posts: 25
##### Re: Dynamic multidimensional array?
« Reply #1 on: 2019-Aug-22 »
bump

#### erico

• Community Developer
• Prof. Inline
• Posts: 4212
##### Re: Dynamic multidimensional array?
« Reply #2 on: 2019-Aug-23 »
I´m not sure I understand what you are looking for and its use, but wouldn´t REDIM help?
If it´s more complex, better wait for the more pro people to chip in on the subject.

#### Snoopy

• Dr. Type
• Posts: 284
##### Re: Dynamic multidimensional array?
« Reply #3 on: 2019-Aug-23 »
Maybe something like that :

Code: GLBasic [Select]

LOCAL x[]
DIM x[44][1]

DMA(x[], 4)

x[0][0] = 506
x[10][1] = 10
x[7][2] = 1004
x[25][3] = 99
x[42][4] = 2019

PRINT x[0][0], 0, 10
PRINT x[10][1], 0, 20
PRINT x[7][2], 0, 30
PRINT x[25][3], 0, 40
PRINT x[42][4], 0, 50

DMA(x[], 2)

x[1][5] = 52
x[37][6] = 308

PRINT x[1][5], 0, 70
PRINT x[37][6], 0, 80

SHOWSCREEN
MOUSEWAIT
END

FUNCTION DMA: a[], n%
LOCAL s1%, s2%

s1 = BOUNDS(a[], 0)
s2 = BOUNDS(a[], 1)

REDIM a[s1][s2 + n]
ENDFUNCTION

« Last Edit: 2019-Aug-23 by Snoopy »