Submit a Story  :  IRAF Links  :  Past Polls  :  Calendar  :  Advanced Search  
     iraf.net
FAQ
 Forum FAQForum FAQ   Forum SearchForum Search   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Writing tasks that accept lists and wildcards

 
Post new topic   Reply to topic    iraf.net Forum Index -> Systems
View previous topic :: View next topic  
Author Message
sirmarcos
Active IRAF User


Joined: 05 Dec 2005
Posts: 32
Location: Gainesville

PostPosted: Wed May 24, 2006 7:04 pm    Post subject: Writing tasks that accept lists and wildcards Reply with quote

What is the trick to allow a task to accept wildcards like file*imh or @filelist?

I have written a very basic task that just passes arguments to another iraf task. I call it qcont and it just takes the file, does a continuum on it with a 1st order spline3 and makes the output file_norm. It works like a charm on one file, but it's unclear to me how I alter the task to accept a list of files... any help or pointers would be appreciated.
Back to top
View user's profile Send private message Visit poster's website
fitz
Site Admin


Joined: 30 Sep 2005
Posts: 3257
Location: Tucson

PostPosted: Wed May 24, 2006 7:17 pm    Post subject: Reply with quote

Hi Marcos,

I assume we're talking about a CL script? If so the trick is to use something like the SECTIONS (or FILES if it isn't an image) task to expand the template, e.g.

Code:

procedure qcont (images)

string  images           { prompt = "Image list" }

begin
    string  imgfile, img

    # Exapnd image template
    imgfile = mktemp ("tmp$qcont")     # get temp file
    sections (images, opt="full", > imgfile)

    list = imgfile
    while (fscan (list, img) != EOF) {
         .....stuff
    }
end


Note some tasks already take image lists and you can just pass it through, other tasks (or pure sccript code) however don't and you need to loop like this.

Cheers,
-Mike
Back to top
View user's profile Send private message
sirmarcos
Active IRAF User


Joined: 05 Dec 2005
Posts: 32
Location: Gainesville

PostPosted: Wed May 31, 2006 6:23 pm    Post subject: Reply with quote

Thanks. That's pretty much what I was asking ... I just wanted to be able to add the @list functionality that most tasks have. And yes, it was a cl script I had written, so the input was just a string, the file name.

I've written cl scripts that accept lists using the fscan loop like you mentioned, but then the input has to be a list, so I'm guessing the "is it a list or is it a file" determination based on whether the @ is there or not is just a matter of parsing the string and using if statements to handle the file as either an image or a list?
Back to top
View user's profile Send private message Visit poster's website
fitz
Site Admin


Joined: 30 Sep 2005
Posts: 3257
Location: Tucson

PostPosted: Wed May 31, 2006 6:59 pm    Post subject: Reply with quote

The SECTIONS task will expand file templates and @files automatically, i.e.

sections foo.fits
sections @flist
sections foo*.fits

will expand the single file name, the contents of the @file, or the wildcard template. Note however that

section flist

will return just 'flist' and not the expanded contents as if you'd used '@flist'.

-Mike
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    iraf.net Forum Index -> Systems All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2009 phpBB Group
 Copyright © 2005-2011 iraf.net
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.25 seconds