home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.pascal:5312 alt.msdos.programmer:2344
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news
- From: holland@matt.ksu.ksu.edu (Rich Holland)
- Newsgroups: comp.lang.pascal,alt.msdos.programmer
- Subject: 3 questions
- Date: 10 Sep 1992 20:38:03 -0500
- Organization: Kansas State University
- Lines: 43
- Message-ID: <18ot9rINN67t@matt.ksu.ksu.edu>
- NNTP-Posting-Host: matt.ksu.ksu.edu
-
- Question 1:
- -----------
- How do I determine if the user is at the command line? I've been thinking
- about writing a TSR to intercept keypresses at the DOS command line and
- expand TABs to full filenames (like tcsh does).
-
- Question 2:
- -----------
- In general, what's the most efficient (fastest) way to search for a small
- string inside a larger one (or for a group of say 5 bytes in a group
- of say 1000 bytes)?
-
- I'd thought of something like this:
-
- For i:=1 to Length(String2)-Length(String1) do
- Begin
- If String1=Copy(String2,i,Length(String1)) then {we found it}
- { so quit for-loop }
- Else { keep looking }
- End;
-
- 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?
-
-
- --
- Rich Holland | INTERNET: holland@matt.ksu.ksu.edu
- 100 Jardine Terr, Apt A7 | BITNET : holland@ksuvm
- Manhattan, KS 66502-3357 | UUCP : ...!rutgers!matt.ksu.ksu.edu!holland
- char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-