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

Home » Public Forums » archive » Re: creating variables in a FOR loop
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: creating variables in a FOR loop [message #79116 is a reply to message #79115] Thu, 02 February 2012 07:07 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
singlebinary writes:

> I would like to read in 6 files and associate 6 variables in which to
> store the information. In the code below, I like to create variables
> which names, "m_0, im_1 and so on. However, I get s 'Syntax error' in
> line 6. Please help! Thanks in advance.
>
> 1 PRO CCFs
> 2 files=file_search('*.fits')
> 3 FOR i = 0, n_elements(files)-1 DO BEGIN
> 4 temp = i
> 5 'im_'+strtrim(temp,2) = mrdfits(files[i],0,h)
> 6 ENDFOR
> 7
> 8 END

I know you *think* this is what you want to do,
but I seriously doubt it is *really* what you want
to do. I would probably use a pointer array (or list,
if you are using IDL 8) to store the images, especially
if they were not all the same size. (If they are
the same size, an array would be my first choice.)

FUNCTION CCFs
files=file_search('*.fits', Count=count)
images = PtrArr(count)
FOR i = 0, count-1 DO BEGIN
images[i] = Ptr_New(mrdfits(files[i],0,h))
ENDFOR
RETURN, images
END

ptr = CCFS()
cgImage, *ptr[3] ; To display the fourth image.

END


Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Coyote Library Update
Next Topic: ANOVA statistical analysis with IDL

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

Current Time: Thu Oct 09 21:58:30 PDT 2025

Total time taken to generate the page: 0.47935 seconds