! ! ! SEARCH.TEC ! ! ! ! Documentation by Robin Miller ! ! ! ! This program is used to search for a specified string in ! ! file(s). The output can be directed to the terminal or a disk file. ! ! Wildcards are permitted thoughout the file specification. Multiple ! ! search strings can be specified and an optional replacement string ! ! can be specified. ! ! ! ! Valid switches are: ! ! ! ! /CHa - Change the search string in the file. ! ! /ABs - Do an absolute (identical) search. ! ! /ESc - Terminate search string via escape. This allows ! ! carriage returns in the search string. ! ! /MAt - Display only files with match of search string. ! ! /DIr - Do directory of files specified in input files. ! ! ! ! All switches must be specified on the "Output file: " question. ! ! ! ! --------------------------------------------------------------------- ! ! ! ! Numeric Q-register usage: ! ! ! ! %0 - Working register. ! ! %1 - The number of lines to display around the search string. ! ! %2 - The numeric parameter passed to the input routine. ! ! %3 - The character to use when building line to display between ! ! files/multiple occurances of a search string. ! ! %4 - The number of files with no matches. ! ! %6 - The page number of file being searched. The page number ! ! is based on the number of formfeeds in the file. ! ! %8 - Flag set true when changing (replacing) the search string. ! ! %C - The number of files not found/not openned. ! ! %F - The character to display after the search string. ! ! %M - The number of files modified. ! ! %T - The number of files searched. ! ! ! ! Text Q-register usage: ! ! ! ! $0 - Working register. ! ! $1 - The macro to display a found search string. ! ! $2 - The terminal input macro. ! ! $3 - The macro built to do the search/replace. ! ! $4 - The file name(s) with no matches. ! ! $5 - The file name to search/replace. ! ! $7 - Storage for display of found search string. ! ! $9 - The output file specification. After the output file is ! ! openned, this register is loaded with a macro to either ! ! write messages to the terminal or to an output file. ! ! $C - The file name(s) not found/not openned. ! ! $S - The macro to prepare message. ! ! ! ! --------------------------------------------------------------------- ! ! ! !SEARCH.TEC V39.00! ! ! ^D 4#2ED 0^X 4,128ET @EI%% ! ! ! $1 - Macro to display the line found with the search string. ! ! ! @^U1/.U0 J Q3-^^-"N ^^*U3 72< Q3@I%% > @I% % G5 @I% % ' Q3@I%% Q3@I%% @I%Page % Q6\ 65+^S< Q3@I%% > ^^-U3 @I% % 0,.X7 0,.K Q0J -Q1L .,Q0:X7 J QF@I%% 0,.:X7 0,.K Q0J Q1+1L Q0,.:X7 G7 ^YM9 ^YK Q0J/ ! ! ! $2 - Terminal Input Macro. The inserted text is left in the buffer. ! ! ! @^U2/+0U2 HX0 HK ET&512"N 0:W-4"E 0,1ET 27^T 1,0ET ^^<^T ' ' !MAIN! EUU0 -1EU :G0 HT Q0EU !CHAR! ^TU0 Q0-27"E 13^T 10^T @O!DONE! ' Q2&2"E Q0-13"E ^T^[ @O!DONE! ' ' Q0-21"E ZJ 0L ZK !LINE! 13^T ET&512"N 0:W-6"N 0,1ET27^T 1,0ET 0:W-4"E ^^[^T ' ^^K^T 13^T 0,1ET 27^T 1,0ET 0:W-4"E ^^[^T ' ^^A^T 13^T 10^T ZJ 0L ."N EUU0 -1EU T Q0EU @O!CHAR! ' @O!MAIN! ' ' 10^T @O!MAIN! ' Q0-127"E Z"N ZJ -1AU0 -D Q0-32"L Q0-10"E ET&512"N 0:W-6"N 2< 0,1ET 27^T 1,0ET 0:W-4"E ^^[^T ' ^^A^T > 10^T @O!CHAR! ' ' ' @O!LINE! ' ET&2"E @O!LINE! ' 8^T 32^T 8^T ' @O!CHAR! ' ZJ Q0@I%% @O!CHAR! !DONE!/ ! ! ! $S - Prepare Message Macro. ! ! ! @^US/US QS"N QS\ | @I%No% ' ^SC5+^S< @I% % > ZJ @I% file% QS-1"N @I%s% '/ ! ! ! Output : For VMS use TT:.SRH, otherwise use TI:.SRH. ! ! ! HK -1EJ-5"E @I%Output : % | @I%Output : % ' M2 ! ! ! /CHA - Change input file (search/replace). ! ! ! J :@FS%/C%%U8 Q8"S ::@FS%H%%"S ::@FS%A%%^[ ' 8U7 | 0U7 ' ! ! ! /ABS - Absolute (identical) search. Upper/lowercase are different. ! ! ! J :@FS%/A%%"S ::@FS%B%%"S ::@FS%S%%^[ ' Q7#1U7 ' ! ! ! /ESC - Terminate search string with escape instead of RETURN. ! ! ! J :@FS%/E%%"S ::@FS%S%%"S ::@FS%C%%^[ ' Q7#2U7 ' ! ! ! /MAT - Display only files with match of the search string. ! ! ! J :@FS%/M%%"S ::@FS%A%%"S ::@FS%T%%^[ ' Q7#4U7 ' ! ! ! /DIR - Do directory of the files to be searched. ! ! ! J :@FS%/D%%"S ::@FS%I%%"S ::@FS%R%%^[ ' Q7#8U7 ' ! ! ! Insert default output file extenstion of .SRH if none specified. ! ! ! Z"N J -1EJ-5"E @:S%]%"U @:S%>%^[ ' ' @:S%.%"U ZJ @I%.SRH% ' ' HX9 HK ! ! ! Input <*.MAC>: For VMS use *.MAR, otherwise use *.MAC. ! ! ! ! Format: *.MAC[/ALL] ! ! ! ! Where [/ALL] is an optional switch to display all files searched. ! ! ! -1EJ-5"E @I% Input <*.MAR>: % | @I% Input <*.MAC>: % ' M2 Z"E @I%*% ' < J -1EJ-5"E @:S%]%"U @:S%>%^[ ' ' @:S%.%"U ZJ @I%.MAC% -1EJ-5"E -D @I%R% ' ' ! ! ! /ALL - Display the file name of all files being searched. ! ! ! J :@FS%/A%%"S ::@FS%L%%"S ::@FS%L%%^[ ' -1U5 | ^^*U5 ' HX5 @EN%^EQ5% [5 HK -1EJ-5"E @I% Input <.MAR>: % | @I% Input <.MAC>: % ' M2 -Z; > 0,4ET HK ! ! ! Lines <3>: Number of lines to display around the search string. ! ! ! ! Format: n[/c] ! ! ! ! The [/c] specifies the character to display following the search ! ! string. The default character is tilda "~". ! ! ! @I% Lines <3>: % M2 ^^~UF J @:S%/^EX%"S -1AUF @FR%% ' 3U1 Z"N J\U1 ' ! ! ! Load the initial commands to do the search. ! ! ! @^U3/0UT 0UC 0,0XC 0UM 0U4 0,0X4 < :]5; @EN%^EQ5% < @:EN%%; G* ^YX5 HK %T^[ Q5U3 / Q8"T ! ! ! Do an edit backup if replacing the search string. ! ! ! :@^U3/EA @:EB%^EQ5%"U %C^[ 9@I%% G5 13@I%% 10@I%% H:XC @EW%% F< ' Y @EW%%/ | ! ! ! Open the file for read only if just searching the file. ! ! ! :@^U3/@:ER%^EQ5%"U %C^[ 9@I%% G5 13@I%% 10@I%% H:XC F< ' Y/ ' ! ! ! Search: Enter search string. ! ! Absolute search: Enter absolute search string. ! ! Replace: Enter the replace string. ! ! ! @:^U3/ 1U6 1,0ED/ HX3 @O!SRH! ' 4,0ET HK G3 ZJ @I/ -^E%6^[ ^N^_; / Q8"T @I/EA P @EW%%^[/ | @I/Y/ ' @I/ >/ Q8"T @I/EA Q3-^^-"E EC %M^[ | EK ' @EW%%^[/ ' @I/HK G5 13@I%% 10@I%% J Q3-^^*"E %4^[ 9@I%%/ Q7&4"F @I/ H:X4/ ' @I/ ' Q3+1"E 72< @I%*% > 13@I%% 10@I%% HM9 ' HK > > HK 72< @I%*% > 13@I%% 10@I%% 13@I%% 10@I%% QTMS @I% searched.% 13@I%% 10@I%% Q8"T QMMS @I% modified.% 13@I%% 10@I%% ' QC"N QCMS @I% not found:% 13@I%% 10@I%% GC ' Q4"N Q4MS @I% with no matches/ Q7&4"F @I%:% | @I%.% ' @I/% 13@I%% 10@I%% G4 ' HM9 EF HK/ ! ! ! Detach : Detach from the terminal. ! ! ! HX3 HK @I% Detach : % M2 :Q9"N @EW%^EQ9% @^U9/PW/ | @^U9/T/ ' Z"N J 0A&(32^_)-^^Y"E 0,64ET ' ' ! ! ! Put a list of all the files to be searched into the editing buffer. ! ! ! @:EG%%^[ HK < :]5; Q7&8"N @EN%^EQ5% J < @:EN%%; Q5\ 10@I%% G* 10@I%% > | J Q5\ 10@I%% G5 10@I%% ' > ! ! ! The next macro reverses the order of the files to be searched. ! ! ! < -Z; ZJ -D 0L ZX5 -L \U5 0L ZK [5 > HK Q7&1"N -1^X ' M3 EX