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

Home » Public Forums » archive » Re: Can IDL create a plain text file?
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: Can IDL create a plain text file? [message #51864 is a reply to message #51863] Thu, 14 December 2006 14:59 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matt writes:

> Question - can IDL create a plain text file of a filelist following
> user specifications? By this I mean that I'd like a text file listing
> files in a directory, but would like to enclose file names in quotes
> and add additional text to it. I imagine that this can be done by
> calling a PERL script but I'm wondering if IDL can do it internally.

Well, suppose you obtained your file list like this:

filelist = File_Search('*.pro')

Then, you could print the list out, with double quotes around
each file name, like this:

OpenW, lun, 'output.txt', /Get_Lun
FOR j=0,N_Elements(filelist)-1 DO BEGIN
PrintF, lun, '"' + filelist[j] + '"'
ENDFOR
Free_Lun, lun

Suppose you wanted to add the index number of the file
to each filename, you could do something like this:

OpenW, lun, 'output.txt', /Get_Lun
FOR j=0,N_Elements(filelist)-1 DO BEGIN
PrintF, lun, '"' + filelist[j] + '"' + ' ' + $
String(j, Format='(I2.2)')
ENDFOR
Free_Lun, lun

You could also format your string with a FORMAT statement
to the PRINTF command, similar to what I used with the
STRING command, above. There is almost infinite flexibility
in how this is done.

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.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Coincident values of string and numbers in 2 arrays..
Next Topic: Zipped Files

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

Current Time: Sat Oct 11 08:19:58 PDT 2025

Total time taken to generate the page: 0.80370 seconds