dynamic arrays

Previous topic - Next topic

Richard Rae

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.

Kitty Hello

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

Kitty Hello

From now on:
Code (glbasic) Select
DIM a[5]
a[4] = 12
REDIM a[8]
PRINT a[4], 0, 0 // prints 12
SHOWSCREEN
MOUSEWAIT