What is the best way to access variable if I know variable string and variable index?

Status
Not open for further replies.

pixel

Advanced Member level 2
Joined
Sep 16, 2004
Messages
508
Helped
69
Reputation
138
Reaction score
16
Trophy points
1,298
Activity points
3,993
What is the best way to acess variable if I know variable string and variable index
varString="a"
varIndex=3
and I want to use variable a3
 

Re: skill question

nth(3 a3)="xyz"
 

Re: skill question

Actually I want to declare some values that does not exist. I just know the beginning of name as a string , and index as a number.

For example:
name should start with value stored in variable nameString="a" I need 5 variables:

a1=1
a2=4
a3=9
a4=16
a5=25


One way to do this is to write theese equations as astring to a file and then load it.

out=outfile("test")
for( i 1 5
fprintf(out "%s%d%s%d%s" nameString i "=" i*i "\n" )
)

close(out)
load("test")
 

Re: skill question

Sure you got the right forum to ask this question?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…