GLBasic forum

Main forum => GLBasic - en => Topic started by: JohnnyB on 2019-Aug-21

Title: Dynamic multidimensional array?
Post by: JohnnyB on 2019-Aug-21
is this possible?

dim x[44][]

does not work, e.g.

Title: Re: Dynamic multidimensional array?
Post by: JohnnyB on 2019-Aug-22
bump
Title: Re: Dynamic multidimensional array?
Post by: erico 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.
Title: Re: Dynamic multidimensional array?
Post by: SnooPI 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