Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
511
Helped
69
Reputation
138
Reaction score
16
Trophy points
1,298
Activity points
3,994
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
 

kokokiki

Junior Member level 1
Joined
Oct 23, 2001
Messages
16
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,283
Activity points
40
Re: skill question

nth(3 a3)="xyz"
 

pixel

Advanced Member level 2
Joined
Sep 16, 2004
Messages
511
Helped
69
Reputation
138
Reaction score
16
Trophy points
1,298
Activity points
3,994
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")
 

Lucifre

Full Member level 2
Joined
Jul 5, 2005
Messages
126
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Location
Detroit MI
Activity points
2,400
Re: skill question

Sure you got the right forum to ask this question?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top