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

Home » Public Forums » archive » Re: simple query: including loop variable in filename?
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: simple query: including loop variable in filename? [message #55900] Fri, 14 September 2007 08:32
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
<id6684@googlemail.com> wrote in message
news:1189766081.164014.99750@19g2000hsx.googlegroups.com...
>
> Hello Folks,
>
> I'm stranded with server downtime (thankfully with net access!) and
> looking to prepare a start on some IDL; can someone tell me please if
> it's possible to include from a FOR loop the variable we are looping
> over in the filename of some kind of file?
>
> eg;
>
> FOR i=0,1 DO BEGIN
> device, filename='i.jpg'
> plot_image, A
> ENDFOR


Others have answered, I just thought I'd add a tip to
include a format='(i3.3)'
command in your string commands, so that you print
out the numbers as 001 002 003. That makes alphabetical
listings go in order, and a bit more convenient to browse
through the files.

Cheers,
bob
Re: simple query: including loop variable in filename? [message #55904 is a reply to message #55900] Fri, 14 September 2007 06:29 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Or...
>
> IDL> Print, StrTrim(j,2) + '.jpg'
>
> if you just want to do it in IDL with what's under
> the hood. :-)

Whoops! That article escaped too soon. Here is an
article that goes into more depth on this topic:

http://www.dfanning.com/code_tips/seqfiles.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: simple query: including loop variable in filename? [message #55905 is a reply to message #55904] Fri, 14 September 2007 06:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> This is the right track but not quite what you want. Doing this has
> a bunch of spaces in the front of the name...
> IDL> print, string(1)+'.jpg'
> 1.jpg
>
> I do this all the time but you need to use trim.pro
> IDL> print, trim(1)+ '.jpg'
> 1.jpg
>
> You can get it here:
> http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/string/trim .pro

Or...

IDL> Print, StrTrim(j,2) + '.jpg'

if you just want to do it in IDL with what's under
the hood. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: simple query: including loop variable in filename? [message #55906 is a reply to message #55905] Fri, 14 September 2007 06:00 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> j=STRING(i)+'.jpg'
> DEVICE, FILENAME=j

This is the right track but not quite what you want. Doing this has
a bunch of spaces in the front of the name...
IDL> print, string(1)+'.jpg'
1.jpg

I do this all the time but you need to use trim.pro
IDL> print, trim(1)+ '.jpg'
1.jpg

You can get it here:
http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/string/trim .pro

Cheers,

Brian

------------------------------------------------------------ ---------------------
Brian Larsen
Boston University
Center for Space Physics
Re: simple query: including loop variable in filename? [message #55909 is a reply to message #55906] Fri, 14 September 2007 04:13 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Sep 14, 11:34 am, id6...@googlemail.com wrote:
> Hello Folks,
>
> I'm stranded with server downtime (thankfully with net access!) and
> looking to prepare a start on some IDL; can someone tell me please if
> it's possible to include from a FOR loop the variable we are looping
> over in the filename of some kind of file?
>
> eg;
>
> FOR i=0,1 DO BEGIN
> device, filename='i.jpg'
> plot_image, A
> ENDFOR
>
> so that I can produce filenames 0,1,2..etc.
>
> Thanks,
>
> David.

j=STRING(i)+'.jpg'
DEVICE, FILENAME=j

should do the trick

Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: simple query: including loop variable in filename?
Next Topic: Re: insufficient system resources

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

Current Time: Wed Oct 08 14:01:38 PDT 2025

Total time taken to generate the page: 0.00821 seconds