comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: best way to find the variable name of a structure from RESTORE-ing a sav file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: best way to find the variable name of a structure from RESTORE-ing a sav file [message #32196 is a reply to message #32195] Fri, 20 September 2002 09:14 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Robert Stockwell (rgs1967@hotmail.com) writes:

> anyone have good ideas on how to programatically find
> the name of a variable in memory, that happens to be
> a structure. The reason I don't know the name is that I
> am restoring a structure from an IDL sav file. The structure
> is the only thing in the sav file.
>
> For instance, I am writing a function like:
>
> function readsavdata, filename
>
> restore,filename=filename
>
> ; here I have a structure in memory, with a variable name I do not know.
>
> help
> ; next line is the result of the help command
> ; IDL> NWS_MMT_FCAST_TEMPERATURE_ARRAY STRUCT = -> <Anonymous> Array[950040]
>
> return, ?????? ; i need the name of this structure
>
> end ; end of function
>
> How do I get this variable name "NWS_MMT_FCAST_TEMPERATURE_ARRAY" so I can
> put in a line like
>
> return,NWS_MMT_FCAST_TEMPERATURE_ARRAY
>
> at the end of the function.

Try this:

Function ReadSavData, filename
Restore, Filename=filename
varname = Routine_Names(Variables=0)
variable = Routine_Names(varname[0], Fetch=0)
RETURN, variable
END

This is not exactly documented anywhere, so your mileage
may vary. It works here in IDL 5.5. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Previous Topic: best way to find the variable name of a structure from RESTORE-ing a sav file
Next Topic: custom color table

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Dec 03 06:41:31 PST 2025

Total time taken to generate the page: 2.08934 seconds