about arrays
#2
An easy solution to your problem is this:

DIM a(10)
FOR f = 1 TO 11
dim a (f)
a(f) = f
NEXT

The dim statement in the loop will do nothing unless it is dimensioning the array larger than it is currently.

This can be seen here:

DIM a(10)
FOR f = 1 TO 11
dim a (f)
print "f ",f
print "arraysize(a(),1) ", arraysize(a(),1)
a(f) = f
NEXT

The resizing in the token / split commands works differently. it removes all the data and then demensions the array up/down to match the number of tokens returned and fills the array with the data from the tokens:

dim ws$(1)
a$="this is a test"
num=split(a$,ws$())
print "num ",num
print "arraysize(ws$(),1) ",arraysize(ws$(),1)

a$="this is"
num=split(a$,ws$())
print "num ",num
print "arraysize(ws$(),1) ",arraysize(ws$(),1)

a$=""
num=split(a$,ws$())
print "num ",num
print "arraysize(ws$(),1) ",arraysize(ws$(),1)


This downsizing only works on single demension string arrays.
Reply


Messages In This Thread
about arrays - by clasqm - 12-21-2017, 08:34 AM
RE: about arrays - by bbjimmy - 01-01-2018, 10:16 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)
Free Web Hosting