1

**GLBasic - en / Re: Dynamic multidimensional array?**

« **on:**2019-Aug-23 »

Maybe something like that :

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

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