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

Home » Public Forums » archive » Re: convert string into the name of a variable
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: convert string into the name of a variable [message #28387 is a reply to message #28377] Thu, 06 December 2001 06:05 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Frederic Raison wrote:
>
> Hi!
>
> Is there anybody who could tell me if there is an IDL instruction, like
> in Matlab, able to convert a string into the name of a variable and
> vice-versa? I mean if I have defined :
>
> a=1
> b=2
> list=['a','b']
>
> I would like to write:
>
> print,somme_instruction(list[0])
>
> and to get:
>
> 1
>
> Thank you
>
> Frederic

Dear Frederic,

as the two others wrote this could be done by execute.
But I like more to learn what's the idea to do this.
For what did you need this?


Another useful routine may be this one:
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/get_main_vars.tar.gz

or if you have a look in import_ascii you can see how it is done without
an execute

At the idl prompt type (This also will work in routines. But then you
have to use the level
keyword)

a=1
b=2
list=['a','b']

result=get_main_vars()
tn=strlowcase(tag_names(result))

;e.g.
ix=(where(tn eq list[0]))[0]

void = ROUTINE_NAMES(tn[ix], STORE=ROUTINE_NAMES(/LEVEL)-1, result.(ix))


I believe this would work in runtime but I am not sure.
The function execute will never work in runtime.

regards
Reimar


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: I have committed a sin CONGRID
Next Topic: Plotting data spanning multiple UTM zones

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

Current Time: Fri Oct 10 09:33:22 PDT 2025

Total time taken to generate the page: 0.24135 seconds