GLBasic forum

Main forum => GLBasic - en => Topic started by: Richard Rae on 2005-Jul-07

Title: dynamic arrays
Post by: Richard Rae on 2005-Jul-07
Is therenany way to vary the size of an array during runtime so that it contains only the range of values that you need.i.e sometimes it may contain no data and other times it could contain a lot of data.
Title: dynamic arrays
Post by: Kitty Hello on 2005-Jul-08
Did you read the tutorial's "adnvanced" section?

You can do this:
Code (glbasic) Select
DIM a[5]
a[4] = 12
DIM a[2][9]
a[1][7] = 2
DIM a[0] // free memory
DIM a[BOUNDS(a,0)+1] // add one to current size
a[0] = 5
Bye,
Gernot
Title: dynamic arrays
Post by: Kitty Hello on 2005-Jul-21
From now on:
Code (glbasic) Select
DIM a[5]
a[4] = 12
REDIM a[8]
PRINT a[4], 0, 0 // prints 12
SHOWSCREEN
MOUSEWAIT