Re: accessing variables with their string names [message #10667 is a reply to message #10664] |
Fri, 19 December 1997 00:00   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Natalie Rooney (natalie@arlut.utexas.edu) writes:
> Hello. I'm trying to create a graphical user interface to do analysis
> and plotting of research data. My widget contains a list widget where I
> display the names of the data the user has read in.
>
> The problem is: I wanted the user to be able to read in a dat file of
> saved variables. I don't know what the names of the variables will
> necessarily be. I figured out a way to get the STRING names of the
> restored variables into an array. But, I still need a way to access the
> data that the variables contain for plots, etc. Is there any way to
> access the variables' data if all you have is a string array of the
> variables' names? I'd appreciate any help.
Uuggh. It is *possible*, maybe, but you will probably run
into limitations. For example, you will have to name
all the "variables" something else in your program to use
them. Here is a short example of how I might approach the
problem using the EXECUTE command. I don't know any other
way that this could be accomplished, really.
Pro Example, varNames
Restore, 'example.sav'
ok = Execute('Plot, ' + varNames[0])
ok = Execute('var2 = ' + varNames[1])
Help, var2
END
a = Findgen(11)
b = 3.5
Save, a, b, File='example.sav'
Example, ['a', 'b']
END
How are you getting the "string" names of the restored
variables?
Happy Holidays,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|