IonicWind Software

IWBasic => General Questions => Topic started by: GJ on December 24, 2006, 08:18:14 AM

Title: DIM
Post by: GJ on December 24, 2006, 08:18:14 AM
Is there a way to assign an array using a variable ??

I used this in Ibasic Standard:


def a:int
' just set a=10, normally this value is read from within the program
a=10
def b$[a]: string
a=2
b$[a]="123"
openconsole
print b$[a]

'stop    --  when in Ibasic standard examining the variables, says array of 10 elements

DO
UNTIL INKEY$ <> ""
end


I like to determine first how many elements the array should be, then dimensioning it by using a variable.



Regards,

GJ




Title: Re: DIM
Post by: Ionic Wind Support Team on December 24, 2006, 08:24:30 AM
Emergence BASIC is a true compiler so array sizes need to be known at compile time.   You can use NEW to create an array of dynamic size.

Paul.
Title: Re: DIM
Post by: GJ on December 24, 2006, 08:26:49 AM
Thank you Paul for your very quick answer. I will have to modify some code then, no problem  ;)

GJ