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

Home » Public Forums » archive » Re: same question with correct reply Email address
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: same question with correct reply Email address [message #28398] Wed, 05 December 2001 15:37
meron is currently offline  meron
Messages: 51
Registered: July 1995
Member
In article <3C0EA820.54127170@hotmail.com>, Frederic Raison <frederic_raison@hotmail.com> writes:
>
> Hi!
>
> Sorry about my wrong email address. ITt was hotmail.com and not
> hotmai.com..
>
> 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
>
You can use EXECUTE. for example

IDL> a = 1
IDL> b = 2
IDL> c = 3
IDL> dum = execute('res=exp(' + list[0] + ')')
IDL> print, res
2.71828
IDL> dum = execute('res=exp(' + list[2] + ')')
IDL> print, res
20.0855

It is useful at times, when you need the flexibility to build up an
appropriate commend within a routine.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: same question with correct reply Email address
Next Topic: Looking for roll correction routine

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

Current Time: Wed Oct 08 13:42:56 PDT 2025

Total time taken to generate the page: 0.00577 seconds