home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
editors
/
amac41.arj
/
SRCH30.QM
< prev
next >
Wrap
Text File
|
1991-08-26
|
63KB
|
1,262 lines
* SRCH30.QM
* Macros To Search/Replace In Text Files And ZIP Files
* Written by Tom Hogshead
* 8/11/91
*
* @(0)* Search/Replace From Command Line:
* - SR.BAT |chg
* - SZR.BAT, search/replace files within ZIP files |chg
* @(4) Search/Replace From Command Line, Quit Each File After Replacement:
* - SRQ.BAT
* @(6) Search From Command Line:
* - SM.BAT (uses MAXFIND)
* @(7)* Search From Command Line:
* - SRL.BAT
* - SZ.BAT, search files within ZIP files, no replace
* * NOTE:Same macro @7 used for SZ and SRL batch files
* Same macro @0 used for SR and SZR batch files
* (See batch files for instructions)
* >>>>>>> (Macros @0_4_6_7 cannot be run while editing) <<<<<<<
*
* @(1)─┐ Makes FileList of files containing search text while editing
* @(2)─┤ Loads FileList of files containing search text while editing
* @(8)─┘ Search/replace while editing loaded files only, |chg
* saves ONLY & keeps loaded ONLY files w/replacements
* @(5) - Search/replace while editing, finds/loads files |chg
* @(9) - Search ONLY loaded files, keep loaded ONLY files w/ found text |chg
* ^(f1_) Find multiple search text in current file, uses FGREP.COM
* ^(f2_) Find multiple search text in current file, uses Dos FIND
* ^(f3_) View another occurrence of search text in current file
* (F4) - RepeatFind
* (F5) - PrevFile
* (F6) - NextFile
* @(a) Moves cursor to first word delimiter after wordleft
* @(f) Moves cursor to first word delimiter after wordright
* ^(a_) Moves cursor to first character of wordleft
* ^(f_) Moves cursor to first character of wordright
* @(h) - Select Index item with cursor line, then <enter>
*
* (CursorLeft) Wrap cursor to previous line like Wordstar does
* (CursorRight) Wrap cursor to next " " " "
* (These two macros, written by Tim Farley, are commented out)
*
* (Index) Use - How to locate macro or item below from Index using @h
* (Description) - Search/Replace Macros
* (Startup) - What's required
* (Environment) Variables
* (Required) Program Files
* (Macros)
* (Other) Macros
* (CAUTION) <<<<<<<<<<<<<<<<<<< IMPORTANT
* (Version) history
*
*-- eoi
* Confirms Saves Must Be
* Replace- Loaded First
* Key Run While ment? Files? Macro? (1) Comments
* ── ───────── ──────── ────── ────── ─── ───────────────────
* @6 cmnd line srch only n/a yes m s/o w/SM.BAT
* @7 cmnd line srch only n/a yes f s/o w/SRL.BAT/SZ.BAT
* @0 cmnd line no yes yes f s/r w/SR.bat/SZR.BAT
* @4 cmnd line no yes/quit yes f s/r w/SRQ.bat
* @1─┐editing n/a n/a no f makes FileList only
* @2─┤editing n/a n/a no f loads files only
* @8─┘editing no rpl only no f s/r loaded files
* @5 editing no rpl only no f s/r finds files
* @9 editing srch only no no f s/o loaded files
* ^F1 editing srch only no no f s/o current file
* ^F2 editing srch only no no f s/o current file
* ^F3 editing n/a no no view another occurrence
* ---------------
* (1) Uses m- MAXFIND, f - FGREP.COM
* (INDEX) USE; To locate a macro or item in this file, press @h, place
* the cursor line on the desired item in the Index above, and press
* <enter>. See BOOKxx.QM for more details.
* (DESCRIPTION): (SRCH30) are QEdit macros to search/replace and search
* only files containing search text from a file pattern or a FileList
* of file patterns to search using FGREP.COM and MAXFIND. Only files
* containing the search text are loaded automatically, and then the
* desired search/replace is performed. Search/replace may be done from
* the command line and while editing files. Search or search/replace
* may be also performed on ZIP files without manually unzipping and
* rezipping.
* In addition to SR, SRL, and SRQ batch files, two additional batch
* files are provided to search and replace files within ZIP's. SZ.BAT
* and SZR.BAT are batch files using FGREP.COM to search and
* search/replace text within ZIP's without having to manually unzip,
* search, replace, and then rezip. For example, at the command line:
* SRZ fff FFF TEST <enter>
* finds all occurrences of "fff" in files within TEST.ZIP and replaces
* it with "FFF". Files containing "fff" are loaded after replacement so
* each replacement can be viewed before re-zip. The user is given the
* option of updating each ZIP on a file by file basis before re-zipping.
* Batch file SM.BAT is also provided to search text files with MAXFIND.
* SM.QM are QEdit macros to use with SM.BAT for searching files
* containing a search string using MaxFind. Files are searched, found,
* and loaded for editing or viewing. The search string, file names, and
* other input or search options may be specified at the command line or
* entered at the option query prompt. "Fuzzy", "and/or", and "sliding
* window" text searches can be done.
* If you wish to do 'case sensitive' search/replace, modify SR.BAT as
* follows:
* FGREP.COM -flc /%S~~%/ %file% >c:\$.ql
* ^
* (STARTUP):
* To BEGIN, just type "START SRCH" <Enter>. All pertinent files will be
* loaded in the "Ring" for viewing, and SRCH30.MAC is read.
* Alternatively, type "START SRCH 0" <Enter> and the disk copies of all
* files in the "Ring" will be loaded ready for editing, saving time.
* To perform a search/replace from the command line, type SR, and
* answer the prompts for search and replace text. To perform a SEARCH
* ONLY from the command line, type SRL, and answer the prompts for
* search text. All searches with these macros and batch files are
* Case insensitive. To perform a case sensitive search, change "GIN"
* to "GN"in the macros below and "-f" to "-fc" in the batch files.
* Search and replacement text may be single or multiple words only
* when answering search and replacement query prompts, not from the
* command line.
*
* Replacing C: with your ram disk will make the macros run faster.
* (ENVIRONMENT) VARIABLES:
* All search and search/replace batch files use environment variables.
* Some environment variables can be set to facilitate use of these
* batch files, however setting any environment variable is optional. If|2.9
* any or all of the following environment variable are *not* set (ie |
* "SET [name]= " the user will be prompted for the required inputs, or
* values can be specified at the command line as described in each
* batch file.
* a) "SET OPT=off" will bypass the option query prompt in SRL.BAT and
* SM.BAT, and bypass the File Name query prompt in SR.BAT and
* SRQ.BAT.
* b) "SET OPT= " will *not* bypass the option query prompt in SRL.BAT
* and SM.BAT, and will *not* bypass the File Name query prompt in
* SR.BAT and SRQ.BAT.
* c) "SET FILELIST=srch-fg.lst" searches with standard file list
* srch-fg.lst in SR.BAT, SRL.BAT and SRQ.BAT. SM.BAT uses the
* program MAXFIND which cannot search from filelists.
* d) "SET FILELIST=c:\srch-fg.lst" searches with standard file list
* c:\srch-fg.lst in SR.BAT, SRL.BAT and SRQ.BAT.
* e) "SET FILELIST=sm.lst" searches with standard file list sm.lst
* for testing SR.BAT, SRL.BAT and SRQ.BAT. SM.LST is provided in
* AMACxx.ZIP. SM.LST is just one line "*.tst" to search SM.TST, and
* any other files with extension .tst.
* f) "SET FILELIST= " will prompt for file name(s) or an @filelist at
* the File Name query prompt. The batch files are written to use
* file list SM.LST if nothing is entered at the File Name query
* prompt.
* the macros used with these batch files must either be located in the
* current directory from which we are searching, or the location of
* these macros must be specified with the environment variable SRMAC as
* follows:
* g) "SET SRMAC= " means macro files are located in current directory
* from which we are searching.
* h) "SET SRMAC=c:\" means macro files are located in c:\ directory.
* c:\ may be any drive:\path\ terminating with a \.
* By default, SZ.BAT and SZR.BAT create, and delete afterwards, a |
* temporary directory c:\$zip$ into which the ZIP file is un-zipped. It|
* is preferable to use a ram drive for speed. An alternative temporary |
* directory can be used by setting the environment variable SZTEMP as |
* follows: |
|2.9
* i) "SET SZTEMP= " uses default directory c:\$zip$ for the temporary |
* directory. |
|
* j) "SET SZTEMP=e:\name" uses directory e:\name (no trailing \) for |
* the temporary directory. |
* Here's my SRCH-FG.LST:
* *.qm
* *.ql
* *.inf
* *.bat
* *.lst
* *.me
* *.doc
* *.syn
* e:\syn\sa.syn
* u:\sr?.bat
* the SA.SYN entry is my PCED synonym file. The batch files have more
* information and instructions.
* the following temporary environment variables are set during batch
* file operation and need not be set by the user:
* S~~ search text
* R~~ replacement text
* file File Name or file list specified at query prompt or
* at the command line.
* All environment variables remain as set during operation so they may
* be viewed with SET afterwards.
* ******* (CAUTION) ***********
*************************************************************************
* Alt_0/4/6/7 set and use the Dos environment variables S~~ and R~~. *
* the letters "S~~" and "R~~" must NOT occur in any other Dos *
* environment variable name or value. If any files being searched have *
* attribute set Read Only, macros will stop when they try to save a *
* Read Only file after replacements have been made. *
*************************************************************************
* You must have enough environment space to store both the search and
* replacement text. I suggest at least 100 bytes.
* QEdit must be named Q.EXE.
* Insert should be ON.
* For (other) macros, see ALLMACRO.INF.
* these macros require "QEdit and QMAC v2.1, February, 1990" or later.
* (REQUIRED) PROGRAM FILES
*
* You──MUST──have the executable program files in AMAC-PRG.ZIP to run
* some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
*
* SemWare
* Exec-PC
*
* It can NOT be found on CompuServe since many of the programs are
* Copyrighted. All program files are ShareWare, and inclusion in
* AMAC-PRG.ZIP is not prohibited in their documentation.
*
* FGREP.COM.ZIP and INPUT.ZIP are the only files necessary to run SR.BAT,
* SRL.BAT and SRQ.BAT. MAXFND23.COM and INPUT.COM are the only files
* necessary to run SM.BAT. FGREP.COM, DX.EXE, PKZIP.EXE and PKUNZIP.EXE
* are required to run SZ.BAT and SZR.BAT.
*
* FGREP.COM can be found on Exec-PC as FGREP172.ZIP. INPUT can be found on
* Exec-PC as INPUT.ZIP. I understand FGREP.COM v2.00 is released but as of
* April 25, 1991 I have not been able to locate it on EXec-PC or
* CompuServe. MAXFIND v2.3 can be found on CompuServe IBMSYS Lib 3 as
* MAXFND.ZIP and on EXec-PC as MAXFND23.ZIP
* See SR.BAT and SZR.BAT for files required to search/replace within
* Zip's.
*
* AMAC-PRG.ZIP contains:
* ----------------------
* Name Length Method SF Size now Mod Date
* ============ ======== ======== ==== ======== =========
* INPUT.ZIP 3097 Stored 0 3097 07 May 86
* MAXFND23.ZIP 24247 Stored 0 24247 26 Apr 90
* RJ.ZIP 9965 Stored 0 9965 01 Dec 90
* FGREP172.ZIP 12513 Stored 0 12513 19 May 90
* DX211.ZIP 100895 Stored 0 100895 17 Mar 89
* AMAC-PRG.INF 3138 Imploded 67 1014 23 Apr 91
* ============ ======== ======== ==== ======== =========
* *total 6 153855 ZIP 1.10 0% 152329 23 Apr 91
*
* these files are probably on many other BBS's also.
*
* I thank the authors for these excellent programs.
* (Macros):--------------------------------------------------------
*
*┌─────────────────────────────────────────────────────────────────────┐
*│ @(0) Macro for search/replace from command line with SR.BAT │
*└─────────────────────────────────────────────────────────────────────┘
* ******** MUST BE FIRST MACRO IN FILE FOR START UP IN SR.BAT*********
* ****** MUST RUN SR.BAT TO USE THIS MACRO******
*
* To do a search/replace from command line, just type SR, and answer
* prompts for search and replacement text.
*
* SRCH.TST is included to show how this macro works. Type/enter at the
* command line as follows:
*
* 1. "SR" <enter>
* 2. "aaa" space "bbb" <enter> (answer SEARCH text prompt)
* 3. "aaa" space "BBB" <enter> (answer REPLACEMENT text prompt)
* 4. SRCH.TST <enter> (answer FileList prompt)
* See SR.BAT to enter parameters at command line.
* This version of @0 also uses the "Once-Around the ring" technique of
* Kyle Watkins. This macro is smaller and faster than Version 1.8 and
* prior because files are loaded by NextFile rather than EditFile, and
* SET >c:\$ is moved to the SR.BAT batch file from the macro.
* When finished running with the batch file or PCED, the following
* files are loaded for viewing or editing:
*
* Window 1 c:\! List of files found & search text (output from FGREP.COM)
* Window 2...n+1 = Files containing search text, n = # files with search text)
*
* IT CANNOT BE RUN WHILE EDITING!
*
* Temporary file names are:
*
* NUL NUL file
* c:\$.ql List of files found & search text (output from FGREP.COM)
* c:\! Same as c:\$.ql
* c:\$ Output of Dos SET.
*
@0 MacroBegin
altwordset * For all file names
* ------------------ display "No found text" message -----------------*
cursordown cursorup * Test if any search text found
jtrue START: * If found, move on
MESSAGE: *
"No found text " * If not found, display this
jump END: * End macro if no found text
START: *
* ---------------------------- load files ----------------------------*
endfile * Get to end of file
LOADAGAIN: *
unmarkblock * Unmark last file name
find #42 "Fi" return "B" return* Find file name
jfalse MESSAGE: * No find ?, show message, end
wordright * Move to space
wordright * Move to file name
markcolumn * Mark it
endline * Get all name in block
copy * Copy file name to scrap
EditFile * Get ready to load
CurrentFilename " " * To force return *here*
Paste Return * Paste file name & do it!
cursorup * Go to next line
jfalse ENDLOAD: * No more filenames? Done load
jump LOADAGAIN: * Check again
ENDLOAD: *
quit * Quit c:\! from ring so no rplc
* -------------------- get search text to scratch --------------------*
editfile "c:\$" return * Load set output file
find "S~~" return return * Find S~~ |27
find "=" return return * Move to = |
cursorright * Move first character |
markcharacter * Mark it |
endline * Move to end of text |
storescrbuff "S~~" return * Store SEARCH text to scratch |
* ------------------- get replace text to scratch -------------------*
unmarkblock * Get ready
begfile * Get to top
find "R~~" return return * Find R~~ |2.7
find "=" return return * Move to = |
cursorright * Move first character |
markcharacter * Mark it |
endline * Move to end of text |
storescrbuff "R~~" return * Store REPLACE text to scratch|
killfile * Kill c:\$ for next time
quit * Remove c:\$ from ring
* --------------- get search/replace text from scratch ---------------*
Editfile "NUL" Return * Insert -or- GoTo NUL File
getscrbuff "S~~" return cut * Cut search text from scratch |2.7
Find paste Return escape * Initialize find prompt
getscrbuff "R~~" return cut * Cut replace text from scratch|2.7
FindReplace return * Begin replacement
paste return * paste REPLACEMENT text
"GIN" * Replace options
* pause ** Add this to pause for options
return * MUST include "GIN"
* ------------------ load files, do search/replace ------------------*
Begline Cursorright * Put cursor in Col. 2 of NUL File
LOOP: * Main test loop
Nextfile * Move to next files in Ring
Cursorleft * Move cursor left (need for NUL test)
Jfalse DOIT: * If couldn't move to left, it's not
* the NUL File AND cursor position
* has not changed -- GO with the
* FindReplace
*ELSE
* Check to see if in the NUL File
Cursorleft * Move cursor left for NUL Test
Jfalse ENDLOOP: * If couldn't move left -- We
* ARE in the NUL File and Need
* to ENDLOOP
*ELSE
Cursorright * Move back to Col. 2 in NUL File
DOIT: * FindReplace Loop
BegFile * Move up in case cursor is below find
Repeatfind * Do the FindReplace
Jtrue SAVE: * If CHANGES are made -- SAVE the File
Quit * If NO CHANGES are made -- QUIT the
* File
Jump LOOP: * Return to the Main Loop
SAVE: * Routine to Save a File with Changes
Savefile * Save the file
Jump LOOP: * Return to Main Loop
ENDLOOP: * Loop is DONE
* -------------------- initialize find for search --------------------*
getscrbuff "R~~" return * Get replacement text from scratch |2.7
cut * Cut replace text from scratch
Find paste return escape * Initialize Find
Quit * Quit the NUL File
END: *
* ------------------------------ reset ------------------------------*
EditFile "c:\!" Return * Load FGREP.COM output as first file
defaultwordset * Set default
*
* 153 bytes Tue 10-02-1990 18:50:33
* 223 bytes Thu 04-25-1991 11:57:13 added find initialize for search
* added "GIN" replace option
* added "No found text" message
* changed file "_" to "NUL", faster
* load FGREP.COM output as first file
* after replacement
* 231 bytes Tue 04-30-1991 22:12:13 changed search and replace to scrap
*
*┌─────────────────────────────────────────────────────────┐
*│ @(1) - makes FileList of files containing search text │
*└─────────────────────────────────────────────────────────┘
@1 MacroBegin
Dos 'FGREP -f0 /' * Make FileList |2.9
Pause *
'/>c:! @SRCH-FG.lst' *
return return *
editfile "c:!" return quit * Edit FileList
editfile return *
begfile *
MarkColumn * Mark begfile c:!
endfile begline * Mark endfile col 1
wordright wordright * Get to file name
cursorleft * Move off file name
DeleteBlock * Delete file name
SaveFile * Save FileList
begfile * Get to begin
MarkColumn * Mark begfile c:!
EndFile * Get to end
gotocolumn "12" return * Get all file names in block
Sort * Sort FileList
killfile * Kill c:!
begfile * See FileList
unmarkblock * Without block mark
*
* 99 bytes Tue 07-02-1991 17:56:32 (TH @1)
*
*┌──────────────────────────────────────────────────────────────┐
*│ @(2) - loads FileList of files containing search text │
*└──────────────────────────────────────────────────────────────┘
* Written by Kyle Watkins, SemWare.
*
@2 MacroBegin
***************************************** LOAD FileList (from QLSTxx)
EndFile BegLine * Start at last line
REPEAT:
UnmarkBlock MarkLine Copy * Grab this name
EditFile * Get ready to load
CurrentFilename " " * To force return *here*
Paste Return * Paste file name & do it!
CursorUp * More lines above?
JTrue REPEAT: * If yes, repeat.
*
* 19 bytes Mon 09-03-1990 00:56:04
*
* --------------------------------------------------------------------
* @(4) Search/replace from command line, quit each file after rplcmnt.
* --------------------------------------------------------------------
*
* Often the total size of files needing a "replacement" will exceed the
* available memory when using SR.BAT and the startup macro @0. Macro @4
* in SRQ.QM is simply a modification of @0 by replacing savefile with
* file, so each file is quit after replacement. See SRQ.QM for this
* macro.
*
* This macro must be the first macro in the file because it is used as
* the startup macro with SRQ.BAT. IT CANNOT BE RUN WHILE EDITING!
* See SRQ.QM for @4.
*
*┌───────────────────────────────────────────────────────────────────┐
*│ @(5) Makes and loads FileList of files containing search text, │
*│ then search/replace loaded files while editing │
*└───────────────────────────────────────────────────────────────────┘
*
@5 MacroBegin
***************************************** GET SEARCH TEXT
unmarkblock *
Editfile 'NUL' Return * Insert -or- GoTo NUL File
"Search Text=" markcolumn pause * Search text?
storescrbuff "1" return copy * Copy search text to scrap
***************************************** GET REPLACE TEXT
RETURN * Move to next line
"Replace Text=" markcolumn pause * Replacement text?
storescrbuff "2" return * Store replacement to scratch
quit * Quit NUL
***************************************** MAKE FileList
DOS 'FGREP -f0 /' * Make FileList |2.9
paste * Paste search text
'/>c:! @SRCH-FG.lst' *
return return *
editfile "c:!" return quit * Edit FileList
editfile return *
begfile MarkColumn * Mark begfile c:!
endfile begline * Mark endfile col 1
jfalse END: * End if no search text found
wordright wordright * Get to file name
cursorleft * Move off file name
DeleteBlock * Delete file name
begfile * Get to begin
MarkColumn * Mark begfile c:!
EndFile * Get to end
gotocolumn "12" return * Get all file names in block
Sort * Sort FileList
***************************************** LOAD FileList (from QLSTxx)
EndFile BegLine * Start at last line
REPEAT:
UnmarkBlock MarkLine Copy * Grab this name
EditFile * Get ready to load
CurrentFilename " " * To force return *here*
Paste Return * Paste file name & do it!
CursorUp * More lines above?
JTrue REPEAT: * Yes ? repeat
killfile * Kill c:!
quit * Quit c:!
Editfile 'NUL' Return * Insert -or- GoTo NUL File
getscrbuff "1" return cut * Cut search text from scratch
Find paste Return escape * Initialize find prompt
getscrbuff "2" return cut * Cut replace text from scratch
FindReplace return * Begin replacement
* paste RETURN * paste REPLACEMENT text
"GIN" Return ** Replace, no prompt
Pause Return * Allow user input of Options
Begline Cursorright * Put cursor in Col. 2 of NUL File
LOOP: * Main test loop
Nextfile * Move to next files in Ring
Cursorleft * Move cursor left (need for NUL test)
Jfalse DOIT: * If couldn't move to left, it's not
* the NUL File AND cursor position
* has not changed -- GO with the
* FindReplace
*ELSE
* Check to see if in the NUL File
Cursorleft * Move cursor left for NUL Test
Jfalse END: * If couldn't move left -- We
* ARE in the NUL File and Need
* to END the Macro
*ELSE
Cursorright * Move back to Col. 2 in NUL File
DOIT: * FindReplace Loop
BegFile * In case cursor is below find
Repeatfind * Do the FindReplace
Jtrue SAVE: * If CHANGES are made, SAVE the File
Quit * If NO CHANGES are made, QUIT the File
Jump LOOP: * Return to the Main Loop
SAVE: * Routine to Save a File with Changes
Savefile * Save the file
Jump LOOP: * Return to Main Loop
END: * Macro is DONE
Quit * Quit the NUL File
*
* 235 bytes Tue 07-02-1991 17:56:57 (TH @5)
* 243 bytes Tue 08-06-1991 22:27:45 (TH @5, replaced '!' with NUL')
* 248 bytes Tue 08-06-1991 22:39:27 (TH @5, set FindReplace option 'GIN')
*
* ----------------------------------------------------------------------
* @(6) - Srch ONLY from command line, loads files w/sm.bat, no replace
* -------------------- uses MaxFind mf.exe -----------------------------
*
* Files containing a search string from a file pattern are searched,
* found, and loaded for editing or viewing. The search string, file
* pattern, and other input or search options may be specified at the
* command line or entered at the option query prompt. "Fuzzy", "and/or",
* and "sliding window" text searches can be done. Text search program
* is MaxFind.
*
* To run, type "sm" <enter>, and answer the prompts. Press F4 to
* view the search string in each file after finding. Alternatively,
* parameters may be specified at the command line.
* See SM.QM for @6.
*
* ┌──────────────────────────────────────────────────────────────────┐
* │ @(7) -Start up macro, loads only found files, no replacement │
* └──────────────────────────────────────────────────────────────────┘
* See SRL.QM for @7.
*
* ------------------------------------------------------------------------
* @(8) MACRO TO EXECUTE the FindReplace ACROSS the ENTIRE RING OF FILES
* ----------------------------------------------------------------
*
* See Kyle Watkin's alternate version below for more discussion.
@8 Macrobegin
Editfile 'NUL' Return * Insert -or- GoTo NUL File
Findreplace Pause Return * Allow user input of Find Item
Pause Return * Allow user input of Replace Item
"GIN" Return * Replace all loaded files, no prompt
* Pause Return * Allow user input of Options
Begline Cursorright * Put cursor in Col. 2 of NUL File
LOOP: * Main test loop
Nextfile * Move to next files in Ring
Cursorleft * Move cursor left (need for NUL test)
Jfalse DOIT: * If couldn't move to left, it's not
* the NUL File AND cursor position
* has not changed -- GO with the
* FindReplace
*ELSE
* Check to see if in the NUL File
Cursorleft * Move cursor left for NUL Test
Jfalse END: * If couldn't move left -- We
* ARE in the NUL File and Need
* to END the Macro
*ELSE
Cursorright * Move back to Col. 2 in NUL File
DOIT: * FindReplace Loop
Begfile * Needed in case cursor is below Find
Repeatfind * Do the FindReplace
Jtrue SAVE: * If CHANGES are made -- SAVE the File
Quit * If NO CHANGES made -- QUIT the File
Jump LOOP: * Return to the Main Loop
SAVE: * Routine to Save a File with Changes
Savefile * Save the file with CHANGES
Jump LOOP: * Return to Main Loop
END: * Macro is DONE
Quit * Quit the NUL File
*
* 62 bytes Sat 09-15-1990 11:17:57 (K. Watkins version)
* 41 bytes Sun 09-30-1990 20:32:55 (this version)
* 45 bytes Tue 08-06-1991 22:30:19 (TH @8, replaced '!' with 'NUL')
* 50 bytes Tue 08-06-1991 22:37:23 (TH @8, set FindReplace option 'GIN')
* * ┌────────────────────────────────────────────────────────────────────┐
* * │@(8) MACRO TO EXECUTE the FindReplace ACROSS ENTIRE RING OF FILES │
* * └────────────────────────────────────────────────────────────────────┘
* *
* * the following macro was written by Kyle Watkins of SemWare in
* * response to my request for a macro to search/replace all loaded
* * files, but also:
* * - save to disk only those files that had a replacement, and
* * - keep loaded only those files that had a replacement made.
* * It is an excellent and creative macro which I urge you to study
* * because of the unique and powerful use of a NUL file as a
* * place-marker.
*
* * ==========================================================================
* * Date: 09-14-90 (11:49) Number: 9940 SemWare Support BBS
* * To: TOM HOGSHEAD Refer#: NONE
* * From: KYLE WATKINS Read: NO
* * Subj: ONCE AROUND the FILE-RING Conf: (0) Main Board
* * ------------------------------------------------------------------------
* * TH>I have been trying for several months to either modify the following
* * TH>macro or come up with another way to search & replace all loaded
* * TH>files but also to:
* * TH>
* * TH> - save to disk only those files that had a replacement, and
* * TH> - keep loaded only those files that had a replacement made.
* *
* * Hi Tom,
* * You may need to adjust this macro at the point where I quit the file
* * if no replacements were made to it (the macro can be adjusted to save
* * those files, if there were some pre-existing changes that were present
* * before the macro was envolked). I wasn't sure what you wanted (my own
* * preference is to retain other changes that I made before I envolked this
* * macro -- BUT I wrote the macro to just Quit those files, since that is
* * what I am guessing you want).
* * Basically, the macro will use the NUL file as a placeholder in the
* * Ring-of-Files. With cursor manipulation, I will determine when you
* * arrive at the NUL file again. Once you get back to the NUL file, the
* * macro will end. Your starting point for the FindReplace throughout the
* * entire Ring will be at the file immediately after the NUL file -- So if
* * you do not have a NUL file already loaded, the starting point will be at
* * the next file from the one that you are currently in. Otherwise, the
* * starting point will be at the next file from the present location of the
* * NUL file.
* * Note that I always return to the original cursor position, before
* * the FindReplace is executed (allowing you to select any Option for the
* * FindReplace routine).
* *
*
* * ------------------------------------------------------------------------
* * MACRO TO EXECUTE the FindReplace ACROSS the ENTIRE RING OF FILES
* * ----------------------------------------------------------------
* *
* @8 Macrobegin
* Editfile 'NUL' Return * Insert -or- GoTo NUL File
* Findreplace Pause Return * Allow user input of Find Item
* Pause Return * Allow user input of Replace Item
* Pause Return * Allow user input of Options
* Begline Cursorright * Put cursor in Col. 2 of NUL File
* *
* LOOP: * Main test loop
* *
* Nextfile * Move to next files in Ring
* Cursorleft * Move cursor left (need for NUL test)
* Jfalse DOIT: * If couldn't move to left, it's not
* * the NUL File AND cursor position
* * has not changed -- GO with the
* * FindReplace
* *
* *ELSE
* * Check to see if in the NUL File
* *
* Editfile
* 'NUL ' Currentfilename Return * GoTo NUL File -- AND--
* * Preload File to Edit
* * Buffer so can Return
* * to Current File
* *
* Cursorleft * Move cursor left for NUL Test
* Jfalse END: * If couldn't move left -- We
* * ARE in the NUL File and Need
* * to END the Macro
* *
* *ELSE
* Cursorright * Move back to Col. 2 in NUL File
* *
* Editfile
* Begline Delch Delch Delch Return * Bring up EditFile Prompt
* * and delete NUL and
* * Return to File we left
* *
* Cursorright * Restore Cursor to its previous
* * position and GO with the FindReplace
* *
* DOIT: * FindReplace Loop
* *
* Repeatfind * Do the FindReplace
* Jtrue SAVE: * If CHANGES are made -- SAVE the File
* *
* Quit * If NO CHANGES are made -- QUIT the
* * File
* *
* Jump LOOP: * Return to the Main Loop
* *
* *
* SAVE: * Routine to Save a File with Changes
* *
* Savefile * Save the file
* Jump LOOP: * Return to Main Loop
* *
* END: * Macro is DONE
* *
* Quit * Quit the NUL File
* *
* * 62 bytes Sat 09-15-1990 11:17:57 (added TH)
*
*
* * ----------------------------------------------------------------
* * I hope this is what you need Tom. Feel free to optimize and alter
* * the macro. The main Body of this macro can be used to allow any kind of
* * ONE-TIME File Ring Sweep. I have already used the main body of the macro
* * (with the necessary adjustments) to Load all files that DO NOT cause a
* * PRESS ESCAPE message -- So I hope it proves useful to you.
* *
* * --... ...--
* * .......Kyle Watkins (SemWare Technical Support)
*
* ----------------------------------------------------------------------
* @(9) Search Only, Keep Loaded Only Files With "Found" Text
* ----------------------------------------------------------------------
* This macro uses the same technique developed by Kyle Watkins in @8,
* to keep loaded ONLY files with "found" text. No replacement or save
* is made (@8 makes replacement and saves files with replacements, but
* files without any replacement are QUIT from ring).
*
* Version 1.6 of this macro used RepeatFind in the DOIT loop. If that
* version was executed more than once and the cursor was on the last
* occurrence of the search text in a file, RepeatFind would NOT find the
* search text again, and the file was QUIT from the ring. Apparently
* RepeatFind does NOT remember the "G" option with Find.
*
* This version replaces RepeatFind with Find "G". Now, if @9 is executed
* more than once, any file with any occurrence of the search text is
* correctly kept loaded.
*
@9 Macrobegin
Editfile 'NUL' Return * Insert -or- GoTo NUL File
Find Pause Return "G" * Allow user input of Find Item
Pause Return * Allow user input of Options
Begline Cursorright * Put cursor in Col. 2 of NUL File
LOOP: * Main test loop
Nextfile * Move to next files in Ring
Cursorleft * Move cursor left (need for NUL test)
Jfalse DOIT: * If couldn't move to left, it's not
* the NUL File AND cursor position
* has not changed -- GO with the
* FindReplace
*ELSE
* Check to see if in the NUL File
Cursorleft * Move cursor left for NUL Test
Jfalse END: * If couldn't move left -- We
* ARE in the NUL File and Need
* to END the Macro
*ELSE
Cursorright * Move back to Col. 2 in NUL File
DOIT: * Find Loop
Find Return "G" return * Do the Find
Jtrue LOOP: * If FOUND -- Return to Main Loop
Quit * If NO FIND -- QUIT the file
Jump LOOP: * Return to the Main Loop
END: * Macro is DONE
Quit * Quit the NUL File
*
* 40 bytes Sun 09-30-1990 22:48:24
* 44 bytes Tue 08-06-1991 22:31:06 (TH @9, replaced '!' with 'NUL')
* ^f1 and ^f2 macros are modifications to macros written by Tim Farley
* in BIGFIND.QM dated 8/21/89 and revised 9/6/89.
*
*------------------------------------------------------------
* ^(f1_) Find multiple search text in current file, uses FGREP.COM
*------------------------------------------------------------
*
* Find all instances of a given string in current file, let the user
* select one, hit return, and view line containing search string.
* Change "c:" to ramdrive for faster operation.
*
* Uses Chris Dunford's excellent FGREP.COM. Remember search string is
* NOT case sensitive.
*
^f1 MacroBegin *
UnmarkBlock DropAnchor * Mark current file to return to
* later
EditFile "c:!" Return Quit * Quit temp file if loaded
* Sets EditFile prompt for later
GotoBlockBeg * Return to where we were
UnmarkBlock * Unmark
DOS 'FGREP -L /' * Prompt for search text |2.9
Pause *
'/>c:! ' * Echo output to temp file
CurrentFilename Return Return * Search current file
EditFile Return * Load temp file with found text
Pause * Pause to select line to view
BegLine WordRight MarkWord * Mark found text line number
Copy * Copy line number to scrap
KillFile * Delete temp file from disk
PrevFile * Return to searched file
GotoLine Paste Return * View found text line
MakeCtrOfScreen * Put on screen center
*
* 67 bytes Tue 07-02-1991 17:57:22 (TH ^f1)
*
*---------------------------------------------------------------
* ^(f2_) Find multiple search text in current file, uses Dos FIND
*---------------------------------------------------------------
*
* Find all instances of a given string in current file, let the user
* select one, hit return, and view line containing search string.
* Change "c:" to ramdrive for faster operation.
*
* Uses Dos FIND. Remember search string is case sensitive.
*
^f2 MacroBegin *
UnmarkBlock DropAnchor * Mark current file to return to
* later
EditFile "c:!" Return Quit * Quit temp file if loaded
* Sets EditFile prompt for later
GotoBlockBeg * Return to where we were
UnmarkBlock * Unmark
Dos 'FIND /N "' * Prompt for search text
Pause '" ' *
CurrentFilename * Search current file
'>c:!' Return Return * Echo output to temp file
EditFile Return * Load temp file with found text
Pause * Pause to select line to view
BegLine WordRight MarkWord * Mark found text line number
Copy * Copy line number to scrap
KillFile * Delete temp file from disk
PrevFile * Return to searched file
GotoLine Paste Return * View found text line
MakeCtrOfScreen * Put on screen center
*
* 65 bytes Sat 02-16-1991 02:55:59
*
*-------------------------------------------------------------
* ^(f3_) View another occurrence of search text in current file
*-------------------------------------------------------------
* Position cursor on line to view another occurrence of search text in
* current file, and hit <enter>. Works only after running either
* ^f1 or ^f2.
*
^f3 MacroBegin *
onewindow * Close all windows
horizontalwindow zoomwindow * Open window full, current file
editfile "c:!" return * Load temp file with found text
begline * Re-position cursor
pause * Pause to select line to view
wordright markword copy * Mark line #, copy to scrap
zoomwindow * Zoom temp file window small
prevwindow * Back to orig file window
begline * Re-position cursor
gotoline paste return * Goto found text line
* pause * Pause to see temp file
zoomwindow * Zoom orig window full
*
* 27 bytes Mon 02-18-1991 00:31:32
*
*┌───────────────────────────────────────────────────────────────────┐
*│@(h) Finds first word on cursor line marked in document below │
*└───────────────────────────────────────────────────────────────────┘
*
* @h macro has 2 steps:
*
* 1. Press @ and h at the same time. An ! shows at the
* end of the top line. Cursor down to desired line in Index.
*
* 2. Press Enter. The macro first erases the !, and
* then finds the first word on the cursor line in the document
* below marked with (...).
*
* See BOOKxx.QM for more details.
*
@h macrobegin
unmarkblock * Unmark any marked blocks
defaultwordset * In case altwordset on
begfile *
endpara * Move to end of Index
markline * Mark it
begfile * Move to bof
find "(" return "L" return * Locate first Index selection line
jfalse NOMARK: *
makectrofscreen * Show top of file
begfile * Move back to bof
unmarkblock markline markline * And highlight line 1
prevposition * Move back to first selection line
begline * Cursor in col 1
pause * Pause for Index selection
wordright markword * Mark first word on line
copy * Copy word to scrap
endpara * Go to end of Index
find "(" paste ")" *
return "I" return * Find first marked word in doc
jfalse NOMARK: *
begline * If mark found go to begline
maketopofscreen scrollup * Cursor on line 2 |a
jump END: *
NOMARK: *
begfile * If no mark found go to begfile
END:
*
* 34 bytes Sun 07-28-1991 15:48:33 (TH @1)
* 52 bytes Wed 07-31-1991 14:43:31 (TH @h, @4 in BOOKxx.QM)
* =========================================================================
* Date: 10-29-90 (13:26) Number: 3156 SemWare Support BBS
* To: EDGAR ESTRADA Refer#: 3155
* From: TIM FARLEY Read: YES
* Subj: Qedit Conf: (21) ILink
* ------------------------------------------------------------------------
* EE>I'm interested in finding out how to get Qedit to wordwrap while using
* EE>the right cursor key.
*
* You mean like WordStar does, where it won't let the cursor move
* out into the "empty space" to the right of the lines?
*
* Here are some macros to do this in 2.1:
*
* *
* * Left and Right cursor definitions that wrap to previous/next
* * line like WordStar does
* *
*-------------------------------------
* (CursorLeft) Macro (line added TH)
*-------------------------------------
*
* cursorleft MacroBegin
* CursorLeft * try to go left
* JTrue end: * succeed! then we are done
* CursorUp * else try to go to prev line
* JFalse end: * if fail, then at top of file. done.
* EndLine * jump to end of previous line.
* end:
*
* 13 bytes Mon 10-29-1990 19:33:07 (line added TH)
*
*-------------------------------------
* (CursorRight) Macro (line added TH)
*-------------------------------------
*
* cursorright MacroBegin
* EndLine * are we at end of line?
* JFalse down:
* PrevPosition * back to where we were
* CursorRight * and right one
* Jump end:
* down:
* CursorDown * try to go to next line
* JFalse end:
* BegLine
* end:
*
* 18 bytes Mon 10-29-1990 19:32:57 (line added TH)
* NOTE: You must have the latest registered release of QEdit 2.1
* to use these macros. Otherwise you will experience odd
* side-effects in the menus and other special contexts where
* the arrow keys have meaning.
*
* there will be an easier way to achieve this behavior in the next
* release of QEdit.
*
* --Tim Farley
* SemWare Technical Support
*------------ (Single line macros for QCONFIG.DAT) ----------------
* cursorleft MacroBegin CursorLeft JTrue Label0: CursorUp JFalse Label1: EndLine Label0: Label1:
* cursorright MacroBegin EndLine JFalse Label0: PrevPosition CursorRight Jump Label1: Label0: CursorDown JFalse Label2: BegLine Label1: Label2:
* Here are four macros that are variations of wordleft and wordright.
* Macros @a and @f position the cursor on the first word delimiter
* after wordleft and wordright. The cursor position will be the space
* following the word as long as no other word delimiter like "," and
* *"." etc immediately follows the word. Macros @a and @f unmark any
* previously marked block, but I don't know any other way to keep this
* from happening. Macros ^a and ^f do almost what wordleft and
* wordright do except the cursor does not stop at the end of a line.
*
* @a Moves cursor to first word delimiter after wordleft
* @f Moves cursor to first word delimiter after wordright
* ^a Moves cursor to first character of wordleft
* ^f Moves cursor to first character of wordright
*
*┌──────────────────────────────────────────────────────────────┐
*│@(a) Moves cursor to first word delimiter after wordleft │
*└──────────────────────────────────────────────────────────────┘
@a macrobegin *
wordleft wordleft * Move wordleft twice
endline * Test if on eol
jtrue NO_EOL: * If not on eol, tests true
wordleft * If on eol, goto wordleft
jump GOTOPOS: * Go to end of word
NO_EOL: prevposition * If not at eol, return
GOTOPOS: * to where we were
markword gotoblockend unmarkblock * Get to end of word
*
* 18 bytes Mon 10-22-1990 11:32:21
*
*┌─────────────────────────────────────────────────────────────┐
*│@(f) Moves cursor to first word delimiter after wordright │
*└─────────────────────────────────────────────────────────────┘
@f macrobegin *
wordright * Move wordright
endline * Test if on eol
jtrue NO_EOL: * If not on eol, tests true
wordright * If on eol, goto wordright
jump GOTOPOS: * Go to end of word
NO_EOL: prevposition * If not at eol, return to
GOTOPOS: * where we were
markword gotoblockend unmarkblock * Get to end of word
*
* 17 bytes Mon 10-22-1990 11:32:32
*
*┌─────────────────────────────────────────────────────────────┐
*│^(a_) Moves cursor to first character of wordleft │
*└─────────────────────────────────────────────────────────────┘
^a macrobegin *
wordleft * Move wordleft
endline * Test if on eol
jtrue NO_EOL: * If not on eol, tests true
wordleft * If on eol, goto wordleft
jump GOTOPOS: * End macro
NO_EOL: prevposition * If not at eol, return to
GOTOPOS: * where we were
*
* 14 bytes Mon 10-22-1990 11:53:14
*
*┌─────────────────────────────────────────────────────────┐
*│^(f_) Moves cursor to first character of wordright │
*└─────────────────────────────────────────────────────────┘
^f macrobegin *
wordright * Move wordright
endline * Test if on eol
jtrue NO_EOL: * If not on eol, tests true
wordright * If on eol, goto wordright
jump GOTOPOS: * End macro
NO_EOL: prevposition * If not at eol, return to
GOTOPOS: * where we were
*
* 14 bytes Mon 10-22-1990 11:53:03
* (F4)
f4 RepeatFind
* (F5)
f5 PrevFile
* (F6)
f6 NextFile
* (VERSION) HISTORY:
*
* 1.0a - Corrected @5 to use @SRCH-FG.lst, not SRCH.lst.
* 1.0b - Modified to not use optional batch file.
* - Removed @5.
* 1.0c - Added Alt_0 for search/replace from command line.
* - Modified SRC.BAT, @1 & @4 for case sensitive search.
* - Modified @4 to re-load search files after replacement.
* - Corrected @1 byte size.
* 1.0d - Removed redundant lines from @0, shortened 31 bytes
* - added START-SR.BAT for quick start.
* - Changed c:srch.ql to c:$.qm in macros and batch files.
* so as to not overwrite qsrch.ql supplied in SRCHxx.ZIP.
* - Added killfile c:$.ql to @1 and @4.
* - Changed FC0 to fc0 in macros and batch files for better
* - visibility.
* 1.0e - Added @5 for prompted replacement from command line
* - Added @6 for prompted replacement while editing
* - Added F4/F6 repeatfind/nextfile
* - Modified @4 for single search/replacement text input.
* 1.0f - Modified SR.BAT and SRC.BAT
* 1.0g - Modified SR.BAT, SRC.BAT and START-SR.BAT.
* - Removed INPUT.COM and INPUT.DOC pending author
* permission to include.
* 1.0h - Removed SRC.BAT, Modified all macros and batch files for
* Case insensitive search
* - Added @7 and SRL.BAT to only load files with search text,
* no replacement
* - Modified SR.BAT to load SRCHxx.MAC on start up.
* 1.0i - Modified @3 to re-load files after replacement.
* - Modified all macros and batch files for case insensitive
* search, some had not been changed in v1.0h.
* - Corrected some macro byte sizes
* 1.0j - Modified comments in SR.BAT, SRL.BAT
* - Modified @7 to about half the size and twice the speed.
* - Included a PCED synonym to search/load files with @7.
* 1.1 - Corrected @7 macro size
* - Removed savefile from old @0
* - Modified @0 to load FGREP.COM found text, after replacement.
* - Added [copy c:$.ql c:!] to SR.BAT
* - Changed FGREP.COM "-f0" to "-f" in SR.BAT, loads found text
* - Removed @5, same thing can be done with @1/2 and
* manual search/replace.
* - Modified srch.ql load filelist for quicker file loading.
* 1.2 - Changed "c:$.ql" to "c:!" in macros @1/4/6, shortened
* each macro 12 bytes.
* 1.3 - Modified @3 to be smaller and faster.
* 1.4 - Changed "*F" to #42 "Fi" in @0 and @7 to be able to load
* this file and SRL.QM with SR and SRL.
* - Modified SRL.BAT to accept SRL [search text] from command
* as long as [search text] is a SINGLE word.
* - Added altwordset to @0 and @7 to correctly load file names
* containing the Altwordset characters.
* - Changed .lst and .ql files.
* 1.5 - Removed E:\up from SR.BAT & SRL.BAT
* 1.6 - Added @8 and @9, modified SR.BAT and SRL.BAT.
* - @3 was deleting first character in loaded files,
* corrected.
* 1.7 - Added @h to help locate items or macros from Index.
* - Added @5.
* - Removed @3, same thing is done better by @8.
* - Removed @4 and @6, same thing is done better with @5.
* - Modified @0 to use the "Once-Around the ring"
* technique developed by Kyle Watkins of SemWare.
* - Modified SR.BAT and SRL.BAT.
* 1.8 - Replaced RepeatFind w/ Find "G" in @9.
* - Modified SR.BAT and SRL.BAT.
* 1.9 - Changed Find initialization in @5 and @0.
* - Modified START-SR.BAT for no search/replace text.
* - Modified @5, @8, @9 and @0 to be shorter and faster.
* - Moved SET >c:$ from @0 macro to SR.BAT batch file.
* 2.0 - Added @a, @f, ^a, ^f variations of wordleft & wordright.
* - Changed quick start file from START-SR to START.
* 2.1 - Added new key definitions for CursorLeft and CursorRight
* to wrap cursor to previous/next line like Wordstar does.
* - Changed SEARCH file names to SRCH.
* 2.1a - Corrected Index Use instructions.
* 2.2 - Modified @7 (SRL.QM) to highlight first occurrence of
* search text.
* - Modified SR.BAT and SRL.BAT to search all files in current
* directory if SRCH-FG.LST does NOT exist in directory.
* - Changed FGREP.COM search target delimiter from " to / in order
* to find strings with " (@1, @5, SR.BAT, SRL.BAT).
* - Added F5 - PrevFile.
* - Added ^f1 & ^f2 to find multiple search text in current file
* using FGREP.COM or Dos FIND. Original macros by Tim Farley.
* 2.3 - Added ^f3 to view another occurrence of search text found
* with either ^f1 or ^f2.
* 2.4 - Added @4 in SRQ.QM to quit each file after replacement
* using SRQ.BAT. Quits file after replacement.
* 2.5 - Removed /LSRCHxx.mac from sr.bat and srl.bat.
* - Removed /LSRQ.mac from srq.bat.
* 2.6 - Added @6 for "fuzzy" & and/or MaxFind searches from command line.
* - Added "No found text" message to @0_4_7.
* - Added find initialize for search to @0 and @7.
* - Added "GIN" automatic replace option to @0 and @4.
* - Changed @0 to load FGREP.COM output as first file after replacement.
* - Added FGREP.COM "-l" line # option to sr.bat, srl.bat and srq.bat.
* - Added /LSRxxxx.mac to sr.bat and srl.bat for F4_6 operation.
* - Added /LSRQ.mac to srq.bat for F4_6 operation.
* - Changed test.qm name to srch.tst
* - Modified SR.BAT, SRL.BAT, SRQ.BAT and SM.BAT.
* - Changed SRCH_Q name to SRQ.
* 2.7 - Changed GOTO 2b to 6a in SR.BAT and SRQ.BAT to stop
* batch file when no file list is entered at query prompt.
* - Changed FGS to S~~ and FGR to R~~ in @0, 4, 6 and 7.
* - Added SZ.BAT and SZR.BAT to search/replace within ZIP files.
* - Changed search and replace to scrap routine in @0 and @4.
* - Changed initialize find routine in @7.
* - Changed all batch file formats.
* 2.8 - Added discussion of environment variable to this file.
* - Added environment variable SRMAC to batch files.
* - Modified batch files for user option to set environment
* variable FILELIST for different file lists. All batch files
* can now be run from any directory.
* 2.9 - Added environment variable SZTEMP to SZ.BAT and SZR.BAT.
* - Removed unnecessary "com" extension from fgrep.com that
* "snuck" into @1, @5, and ^F1.
* - Changed "c:$.ql" to "c:\$.ql" in SRL.BAT.
* 2.9a - Corrected Index. Included in AMAC39.ZIP, July 21, 1991.
* 2.9b - Changed documentation.
* - Added latest version of @h. 8/2/91
* (Included v2.9b in AMACxx v4.0)
* 3.0 - Changed file name in @5, @8 and @9 from '!' to 'NUL'. 8/6/91
* - Changed FindReplace option to "GIN" in @5 and @8. 8/6/91
* - File name changed in SR.BAT and SZR.BAT in version change. 8/6/91
* - Added instructions to do case sensitive search/replace. 8/9/91
* - Removed dummy.zip from test.zip. 8/11/91
*
*
*
*
*
*