May 29, 2024, 10:56:22 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


DIM

Started by GJ, December 24, 2006, 08:18:14 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

GJ

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





Ionic Wind Support Team

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.
Ionic Wind Support Team

GJ

Thank you Paul for your very quick answer. I will have to modify some code then, no problem  ;)

GJ