Page 1 of 1

create multiple variables in loop

Posted: Wed Feb 22, 2017 8:06 pm
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

Re: create multiple variables in loop

Posted: Thu Feb 23, 2017 8:41 am
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$)