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

Home » Public Forums » archive » Re: Is it possible to set a string to a veriable name?
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: Is it possible to set a string to a veriable name? [message #67941 is a reply to message #67939] Fri, 04 September 2009 06:26 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Sep 4, 6:36 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
> I have an array of string and want to use its elements as veriable
> names in a function.
> How can I do?
>
> Is there any simple code to replace the ones below?
>
> For example:
> STR = ['a', 'b', 'c', 'd', 'e']
> for i=0, 4 do begin
>       case i of
>             0: data=a
>             1: data=b
>             2: data=c
>             3: data=d
>             4: data=e
>         endcase
>   ..............
>   ..............
>   ..............
> endfor

You could use EXECUTE(). Something like:

result = execute('data='+STR[i])

'course it won't work in the vm...
[Message index]
 
Read Message
Read Message
Previous Topic: IDL set_plot
Next Topic: Re: IDL set_plot

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

Current Time: Sun Nov 30 05:52:10 PST 2025

Total time taken to generate the page: 0.80458 seconds