home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff374.lzh / Mat / SCH < prev   
Text File  |  1990-10-08  |  2KB  |  44 lines

  1. .K FROM,SEARCH/A,ALL/S,>/K
  2. .BRA {
  3. .KET }
  4. ;;    SCH   --  A SEARCH Surrogate, that's about twice as fast as
  5. ;;          the AmigaDOS command or more (on long files only, of course
  6. ;;          -- the directory searching part is disk limited).
  7.  
  8. if "{ALL}" eq ""    ;; don't search multiple directory levels
  9.     if "{>}" eq ""  ;; no redirection wanted
  10.       MAT S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}
  11.     else            ;; redirect output to desired file
  12.       MAT >{>} S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}
  13.     endif
  14. ;; Mat command line arguments:
  15. ;;      S {SEARCH}  -- search for the supplied parameter as a string
  16. ;;      nocase      -- ignore case in the match
  17. ;;      tag ^P..^|^P..  -- output "<pathname>..." before each file
  18. ;;                         tag has the same success and fail parts.
  19. ;;      T "  ^N  ^O"    -- template specifies output format as:
  20. ;;                          "<line-number>  <original-line>".
  21. ;;      {FROM}      -- file spec to search
  22. ;;
  23. else    ;; ALL specified
  24. ;; -- the Mat commands below are similar to the above, except that
  25. ;;    multiple directory level file specs are supplied.
  26.   ;; check the spec to see if it is a device, parent, or null:
  27.   MAT #?:|/|% key {FROM}
  28.   ;;    -- returns WARN of not (no match between pattern and key argument)
  29.   if WARN   ;; -- insert a "/" after parameter
  30.     if "{>}" eq ""
  31.       MAT S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}/#? {FROM}/#?/#? {FROM}/#?/#?/#? {FROM}/#?/#?/#?/#? {FROM}/#?/#?/#?/#?/#?
  32.     else
  33.       MAT >{>} S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}/#?/#? {FROM}/#?/#?/#? {FROM}/#?/#?/#?/#? {FROM}/#?/#?/#?/#?/#?
  34.     endif
  35.   else      ;; -- use parameter without adding "/"
  36.     if "{>}" eq ""
  37.       MAT S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}#? {FROM}#?/#? {FROM}#?/#?/#? {FROM}#?/#?/#?/#? {FROM}#?/#?/#?/#?/#?
  38.     else
  39.       MAT >{>} S {SEARCH} nocase tag ^P..^|^P.. T "  ^N  ^O" {FROM}#? {FROM}#?/#? {FROM}#?/#?/#? {FROM}#?/#?/#?/#? {FROM}#?/#?/#?/#?/#?
  40.     endif
  41.   endif
  42. endif
  43.  
  44.