RE: Converting a string to a variable name
- Posted by irv at take.maxleft.com Jul 28, 2002
- 528 views
rubis at fem.unicamp.br wrote: > Hi all; > > Direct to the point... > > I'm writing a program that uses a lot of sequencial variables: > > a1, a2, a3... > > and give values for then: > > a1=1, a2=2, a3=3 ...(for example) > > > I would like to do this: > > atom a1,a2,a3 > sequence s > for x=1 to 3 do > > s=sprintf("%d",x) > "a"&s=x -- atribute a "variable variable" name > > a variable value :>)) > > end for > > but this does not work because "a"&s is a string, not a variable. > > How I can convert a string to a variable name ?? You can't, but is there any reason you cannot use an array of atoms? object a a[1] = 1 a[2] = 2 ...etc for x = 1 to 3 do a[x] = ?? Irv