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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: best way to find the variable name of a structure from RESTORE-ing a sav file [message #32195] Fri, 20 September 2002 10:00
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Robert Stockwell wrote:
> 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.
>


Dear Robert,

you should have a look at the Craig Markwardt library about restore.

cmrestore


You find it at http://astrog.physics.wisc.edu/~craigm/idl/idl.html



Reimar
>
> 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. I suppose I can capture and parse the help
> command and issue an execute command, but there must be a way to find
> that info
> that is a little nicer.
>
>
>
>
> Cheers,
> bob
>


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sat Oct 11 10:27:08 PDT 2025

Total time taken to generate the page: 0.56119 seconds