create multiple variables in loop

Post Reply
Erg2
Posts: 18
Joined: Sat Dec 10, 2016 8:58 pm
My devices: ipad2
Flag: Australia

create multiple variables in loop

Post by Erg2 »

hello
I'm trying to create multiple variable in a loop, assign values to the created variables, then use the created variables and assigned values in new calculations outside of the loop. I'm getting zero's for f,g,and h. How can I make this work? thanks

a=50
b=5
FOR i=1 TO 5
x$="FL"
y$=y$+1
z$=x$&y$ 'concatenate to give FL1, FL2 and so on
PRINT z$
z$=a+b 'assign calculated value "a+b" to each FL1,FL2 and so on
PRINT z$
NEXT i

'use created FL1,FL2 and so on, and assigned values in new calculations
f=FL1+FL2
g=FL5-FL3
h=FL4*FL1
PRINT f
PRINT g
PRINT h

User avatar
Dutchman
Posts: 860
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: create multiple variables in loop

Post by Dutchman »

There is a basic difference between strings and numbers.
"9" and 9 are two different things and can not be used in mathematical expressions.
Conversion between these 'things' can be done with the commands VAL(s$) and STR$(s$,f$)

Post Reply