home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.pascal:5315 alt.msdos.programmer:2347
- Newsgroups: comp.lang.pascal,alt.msdos.programmer
- Path: sparky!uunet!cs.utexas.edu!torn!news.ccs.queensu.ca!slip207.telnet1.QueensU.CA!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: 3 questions
- Message-ID: <dmurdoch.70.716177266@mast.queensu.ca>
- Lines: 33
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <18ot9rINN67t@matt.ksu.ksu.edu>
- Date: Fri, 11 Sep 1992 02:07:46 GMT
-
- In article <18ot9rINN67t@matt.ksu.ksu.edu> holland@matt.ksu.ksu.edu (Rich
- Holland) writes:
- >Question 3:
- >-----------
- > I know how to detect if redirection is in effect (so don't send me the
- > FAQ, Timo! *grin*), but how do I let my programs use this? I'd like
- > to write a "File filter" that could be used like this:
- >
- > type filename.txt | myfilter > newfile.txt
- >
- > or
- >
- > myfilter filename.txt > newfile.txt
- >
- > In other words, I'd like to figure out where my input is coming from,
- > and open a file if necessary, or just take what's passed to me via the
- > pipe (if there is one)...does that make sense?
-
- If your program's calling syntax is really that simple, then a nice trick to
- get what you want is the following:
-
- assign(input,paramstr(1));
- reset(input);
-
- This way, if your program is called with no parameters, it reads from
- standard input; if it has one parameter, it reads from that. If you want
- more complicated syntax (e.g. option flags), then you'll have to do the same
- sort of thing in a more complicated way.
-
- P.S. Can't help you with Q1 and Q2!
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-