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

Home » Public Forums » archive » Re: turn a string value into variable 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: turn a string value into variable name [message #63040 is a reply to message #63039] Thu, 23 October 2008 15:56 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Nick writes:

> I am restoring over 100 .sav files and creating structures for
> analysis. Each .sav represents a differenct scenario and ideally I
> would like to name the created structure in sequential format (case1,
> case2...casen).
>
> To pull the data in I am using a for loop (all .sav have identical
> array names) and I'd like to use the counter to name the variable. Is
> it possible to turn a string into a variable name?

The EXECUTE command can do this:

FOR j=0,n DO BEGIN
IF Execute('case' + String(j, Format='(I3.3)') + $
'= mysavedStruct') EQ 0 THEN $
Print, 'We have a failure to execute!'
ENDFOR

At one time there was a limit on the number of new
variables that could be created this way inside an
IDL program. I believe that limit has been removed.

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Two new IDL Help Articles describing how to use the Workbench are made available now.
Next Topic: Re: meanclip

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

Current Time: Fri Oct 10 02:48:13 PDT 2025

Total time taken to generate the page: 1.43940 seconds