! search.tes - Macro program to search a pre-prepaired list of files for the occurance of a specified text pattern. Copyright (c) 1980, 1982, 1990, by Network-Systems Design, Inc. History: 10-JUN-80 Written for use with RT-11 Teco by Michael C. Bandy for Network-Systems Design, Inc. 23-APR-82 Modified for use with OS/8 Teco by MCB for NSD 3-NOV-90 Modified for use with uTeco-86 by Jim Dempsey for Network-Systems Design, Inc. 2-MAR-91 Modified to be SQUed Calling format: C>teco -msearch list or Ilist$:EIsearch$ or 1:EIsearch$ List in buffer 1, returns list to buffer 1 ! !search.tec! +0 ! incase no entry arg force one of 0 ! [C [D [F [L [M [S [V ! save working registers ! UL ! place entry arg (+0) into L.num ! @^A% Search.tec - Copyright (c) 1980, 1982, 1990, Network-Systems Design, Inc. Oshkosh, WI 54901 USA % QL"E ! if no entry arg ! Z"E ! if buffer empty ! @I%Enter name of file list: % ! insert prompt ! 13:@EI%gettext%"E ! if gettext gets nothing ! @O!Exit! ! exit (cleanup stack on the way out ! ' ! endif nothing entered ! ^SC ! backup by the amount of text entered ! 0,.K ! kill the prompt ! ' ! endif buffer empty ! J ! jump to the front of the buffer ! :@S~^M~"S ! if we find a ! R ! backup over the ! .,ZK ! kill to ehd of buffer ! ' ! endif we found a ! ! At this point the edit buffer has a filespec! ! of the file that contains the list of files ! ! to scan. ! HX* ! copy the text buffer into filespec ! HK ! clear buffer of filespec ! :::@ER%%"F ! if (colon-anchored ER) open fails ! @^A%List not found! % ! type error message ! @O!Exit! ! go to exit ! ' ! endif ! 2ED ! enable yanks to trash buffer ! 1B ! edit buffer 1 ! HK ! kill it too ! Y ! Pull in the list in buffer 1 ! | ! elseif buffer 1 already has the list ! 1B ! just select buffer 1 ! ' ! endif ! HXF ! make copy of list in F.str ! HXD ! and D.str ! 0B ! select buffer 0 ! < ! main command loop ! HK HXL ! kill buffer and L.str ! @I%Enter uTeco format search string (finish with Ctrl-Enter): % :@EI%gettext%"E @O!Exit! ' ! get text string for search macro ! ! exit if none entered ! ^SC ! backup over search string ! 6W ! set display height to 6 lines ! 0,.K ! kill prompt ! @^US%:_% ! build a :_ ! H:XS ! :_filespec ! 27:@^US%% ! :_textentered ! :@^US&"F ! if search fail ! @^A% String Not Found % 0F> ! exit S.str with search fail ! ' ! endif search fail ! @^A% String Found % 10< ! loop to display this and some other matches ! V ! display this match ! :@_%%; ! possibly find another match ! > ! end loop ! -1 ! exit S.str with success ! & ! end insert into S.str ! HK ! kill text buffer ! GD ! get original list ! HXF ! recopy to F.str ! < ! loop ! HK ! kill buffer ! GF ! get remaining files to scan ! -Z; ! iif list empty exit loop ! J ! jump to start of buffer ! L ! advance one line (file) ! 0,.-2XV ! copy filespec to filespec buffer no crlf ! 0,.K ! kill filespec + ! HXF ! remainder of list into F.str ! HK ! kill buffer again ! @^A% File Is: % :GV ! display "File Is: filespec" ! :@ER~^EQV~"F ! if file open fails ! @^A%File Not Found % F< ! print error, go on to next file ! ' ! endif file not found ! Y ! fill up the buffer ! MS"F F< ' ! iif search fails go on to next file ! HK ! kill any residual part of the file ! GV ! get the filespec ! @I% % ! + ! H:XL ! append to found file list ! > ! end file loop ! HK ! kill buffer ! @I% End Of The List -- Here's The Matches: % 20W ! display height to 20 lines ! GL ! get list ! ^SC ! backup in front of list ! < ! loop to reformat list ! :@FS% % %; ! replace with 16 spaces ! -(0^Q&15)D ! delete back to mod 16 column ! 0^Q+(^Q)-81"G ! if next filespec won't fit on line ! @I% % ! insert ! W ! update the display on line break ! ' ! endif line too long ! > ! end reformat loop ! @^A% Re-do search (y/n)?% :@EI%yesno%UV 27^T @^A%[1;1H% ! type [1;1H Home ! 27^T @^A%[J% ! type [J Clear to end of screen ! QV"E ! if yesno returned no ! 1B ! select buffer 1 ! HK ! kill buffer 1 ! GL ! get the list ! 0; ! exit the main loop ! ' ! endif no ! > ! end main loop ! !Exit! 0B HK GL ! place list into buffer 0 too ! ]V ]S ]M ]L ]F ]D ]C ! restore registers !