home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / pascal / 5312 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.9 KB  |  55 lines

  1. Xref: sparky comp.lang.pascal:5312 alt.msdos.programmer:2344
  2. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news
  3. From: holland@matt.ksu.ksu.edu (Rich Holland)
  4. Newsgroups: comp.lang.pascal,alt.msdos.programmer
  5. Subject: 3 questions
  6. Date: 10 Sep 1992 20:38:03 -0500
  7. Organization: Kansas State University
  8. Lines: 43
  9. Message-ID: <18ot9rINN67t@matt.ksu.ksu.edu>
  10. NNTP-Posting-Host: matt.ksu.ksu.edu
  11.  
  12. Question 1:
  13. -----------
  14.   How do I determine if the user is at the command line?  I've been thinking
  15.   about writing a TSR to intercept keypresses at the DOS command line and
  16.   expand TABs to full filenames (like tcsh does).  
  17.  
  18. Question 2:
  19. -----------
  20.   In general, what's the most efficient (fastest) way to search for a small
  21.   string inside a larger one (or for a group of say 5 bytes in a group
  22.   of say 1000 bytes)?
  23.   
  24.   I'd thought of something like this:
  25.  
  26.   For i:=1 to Length(String2)-Length(String1) do       
  27.     Begin
  28.     If String1=Copy(String2,i,Length(String1)) then {we found it}
  29.                                                     { so quit for-loop }
  30.     Else { keep looking }
  31.     End;
  32.  
  33. Question 3:
  34. -----------
  35.   I know how to detect if redirection is in effect (so don't send me the
  36.   FAQ, Timo!  *grin*), but how do I let my programs use this?  I'd like
  37.   to write a "File filter" that could be used like this:
  38.  
  39.     type filename.txt | myfilter > newfile.txt     
  40.  
  41.                or
  42.  
  43.     myfilter filename.txt > newfile.txt
  44.  
  45.   In other words, I'd like to figure out where my input is coming from, 
  46.   and open a file if necessary, or just take what's passed to me via the
  47.   pipe (if there is one)...does that make sense?
  48.  
  49.  
  50. -- 
  51. Rich Holland              | INTERNET: holland@matt.ksu.ksu.edu
  52. 100 Jardine Terr, Apt A7  | BITNET  : holland@ksuvm
  53. Manhattan, KS  66502-3357 | UUCP    : ...!rutgers!matt.ksu.ksu.edu!holland
  54. char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  55.