|
Related
macros:
If you simply want to use a
macro to quickly apply colored highlighting or font
attributes (e.g., bold, italics, or redline) to several
different words in a document -
- All users: See HiLiteDoc
to add colored highlighting to one or more different words/phrases.
- Advanced users: See the macros in the
footnotes below.
If you want to replace or
augment (or remove) a font attribute (e.g., bold) with one or more
other font attributes (e.g., bold+italic) -
|
Purpose
Replacem.wcm
is a macro that you can use to find and replace many words or phrases
in the current document in one easy operation. With it you can make
extensive changes to existing documents with a mouse click.
Why use it? WordPerfect's
QuickCorrect only works to replace words as you type; it can't find and
replace existing (i.e., already typed) words. For that you usually use
Edit, Find and Replace. But Find and Replace only works with a word or
a phrase at a time, whereas this macro can work with dozens of words or
phrases at a time.
Replacem.wcm is useful
whenever you need to make more than a few Find-and-Replace passes in a
document -- especially if you need to repeat the same operation using
the same words on additional documents (the macro uses simple
user-created files to store find/replace items).
[Screen shot of Replacem.wcm menu]
Tips WordPerfect X6 (released in 2012) ships with a new macro,
MultipleFindandReplace.wcm. However, unlike Replacem.wcm, it
does
not allow prompting the user for confirmation and it does not store the
find/replace items for future use. But for current-session use with
simple words/phrases, it is easier to use since no separate user document containing replacements
is required. Simple alternatives: If you simply want to use a custom macro to quickly
apply font attributes (e.g., italics or redline)
to several different words in a document, or replace several items with other items, etc., without
creating a separate user document containing search items and their
replacements (required with Replacem.wcm), see the macros in the
footnotes below.
Instructions and operation
[These instructions also exist at the top of the macro's code.] Step 1. You must create and save at least one ordinary, separate
WordPerfect document (.WPD) containing a list of your items and their
replacements. The words must be in a 2-column table in plain text (no
formatting codes), as explained below. This separate document will be "called" by the macro to make the replacements to the specified items in the main document. This
is easy to do with Table, Create (or Format, Table, Create in earlier
versions of Wordperfect). Be sure the separate document contains only
a 2-column table, with the first column containing the word or words to
replace, and the second column containing the replacement word or
words -- each pair in the same row -- something like this:

When creating the list: Use plain text. Don't use any formatting (fonts, font sizes, bold, italics, etc.) for the items in the table. Don't paste.
It is better to type the items into the list rather than paste them as
unformatted text with Edit, Paste Special since doing this (as of
WordPerfect 11; see here) converts normal hyphens (which are codes) into hyphen characters
("hard hyphens"). This means the normal-hyphen item in the document
will not be found. Instead, just press the hyphen key if that is the
way it was entered in the main document. If
you are not sure about the type of hyphen in the document at the
item's location you can simply add both versions of the hyphenated item
to the table list (each in their own table row). Don't add anything around the table. The only thing in the document should be the 2-column table. Keep the items in Column 1 short. The word or phrase in Row 1,
Column 1 is limited by WordPerfect's Find function to
about 79 characters, so keep all items under this length. Each item in Column 1 will be replaced by the word or
phrase in the same row (in Column 2). Empty cells? During
playback, if the macro runs into an empty cell in Column 1, it will
terminate immediately, so you don't need to worry about empty rows
below your list of replacement words. However,
don't leave empty cells in Column 1 in the middle of your list, or all
words following that location won't get replaced. But
... a blank cell in Column 2 means the adjacent word or phrase in
Column 1 will be replaced with "nothing" (which may still leave behind
an extra space). This is the equivalent of manually
using WordPerfect's Find and Replace function with <nothing>
entered in the Replace field. Spaces, periods (full stops), and hard returns? Don't forget to include
spaces or periods where needed in the table cells, especially after any
replacement sentences (i.e., Column 2 items), and be sure to exclude hard returns in Column 2 of the table (unless you really want them). Step 2. Save the document to disk. IMPORTANT: This
replacement list document must be named REPLACEM.WPD (note the "M" at the end) and be saved in your default macros
folder, along with this macro.
To find the location of your default macro folder:
Click Tools, Settings,
Files, Merge/Macro and jot down the name. [You could save the table
document to your regular default folder and then move it to the
macro folder with Windows Explorer.] You
can create up to 9 additional word list files, naming them (in
sequence) REPLACE2.WPD (for the second list) through REPLACE0.WPD (for the last list), to match the macro's
menu selections. Tip:
You can also change the names to something more meaningful. If you do
that, you must also change the macro code in the Menu section of
this macro's code to
match the new flenames. Step 3. Play the macro
on the current document (always make a backup of the document before
you begin). Tip:
If you have set Undo to "on" (with Edit, Undo/Redo History), you can
quickly reverse any changes to your current document with Ctrl+Z. Alternatives
- Advanced users: If you simply want to use a custom macro to quickly
apply font attributes (e.g., italics or redline)
to several different words in a document, or replace several items with other items, etc., without
creating a separate user document containing search items and their
replacements (required with Replacem.wcm), see the macros in the
footnotes below.
- If you want to swap
words or phrases -- for example, "Party 1" and "Party 2" -- wherever
they appear in your document, use the "A-B-C Word Triangle" method.
Imagine a triangle with the first word (or list of words) located on
one corner (say, the lower left, or corner "A"), the second word(s) on
the opposite corner (lower right, or corner "B"), and some sort of
intermediate word(s) at the apex (or corner "C"). You need to change
"A" words to (intermediate) "C" words to "park" them out of the way
temporarily. In effect, the "A" words no longer exist in the document.
Then you need to change "B" words to "A" words (the first part of the
swap). Finally, you need to change the intermediate "C" words to "B"
words, completing the swap. The net result is that you have swapped "A"
words ("Party 1") with "B" words ("Party 2"). Here's how:
- First replace the first
word or phrase (e.g., "Party 1," which is Word A) with an intermediate
word (Word C) not used elsewhere in your document. A "nonsense" word
will do nicely, such as ABCD1. This "parks" the word or phrase out of
the way temporarily. If you are replacing several words or phrases at
once using a separate word list, replace the next word or phrase on
your swap list with ABCD2, etc. In this step, you are replacing all "A"
list words with "C" list words.
- After the replacements
have been made with nonsense words, replace the second word or phrase
with the first. For example, replace "Party 2" with "Party 1". In this
step, you are changing all "B" list words into "A" list words.
- Finally, replace the "C"
list words (the nonsense words) with the corresponding "B" list words.
- If you are using lists
of words, you will need three lists for this method. In our example,
the first row of the first list would contain the words "Party 1" and
"ABCD1." The first row of the second list would contain the words
"Party 2" and "Party 1." the first row of the last list would contain
the words "ABCD1" and "Party 2." You would play the macro three times
using each of the three lists in turn.
- For a simple macro that
swaps any two selected items (e.g., "Party 1" and "Party 2") throughout
a document, see SWAPTHEM.
|
Footnote 1
If you only need to apply formatting
(bold, italics, etc.) to several different
words or phrases in a document -- wherever they are found -- you can
use a macro like the one below. (It is based on a macro published by
Greg
Turner and Kenneth Hobson on WordPerfect Universe here.) Tip: For a simple version that
you can create without the need to set up a separate "source list"
file, see the next macro in Footnote 2
below.
Assume you wish to
apply italics to these words that might appear
anywhere in a document:
Agreement Assignment Leased Premises Master Lease Transferor Transferee
Instructions
The simplest thing to do is
first create a separate,
plain text (ANSI or ASCII) file with each item on a separate
line.
(This "source word" file
can be created with a text editor, or it can be created in WordPerfect
and saved as ANSI Text. For a simpler version of this macro that might
appeal to those who write macros "on the fly," see Footnote
2 below.)
Then modify the macro code
below (the items in red) to
point to the text file and to tell the macro which attribute to apply.
Then play the macro.
Notes
- Keep all words and
phrases in the source word file to less than 79 characters per item,
including spaces. This is a limit of the macro language's SearchString()
command. While longer items can be written and stored into the macro's Array[]
command, only the first 79 characters/spaces of a matching item will be
processed (in this example: italicized) in the document.
- Note that the macro
searches for items that match the item's case.
Thus, "Agreement" will be processed, but not "agreement." You can
change this in the SearchCaseSensitive() command in
the ForEach() loop. You can also change the SearchFindWholeWordsOnly()
command to process partial words.
- Other font attributes or
relative sizes can be used besides italics; see the variable (vAttr)
at the top of the macro's code. Use a number that corresponds to the
attribute (e.g., 8=Italics).
- Once the words are
processed, you can instantly delete the attributes, add additional
attributes, or change attributes with Ron Hirsch's REPLACE CODES macro here.
Tips
- To copy the macro code
into WordPerfect, see here
for instructions.
- Always test the effects
of the macro on a copy of your document (or a section of your document)
to see how it works.
Example
macro to add italics
to various words using an external source list of words
|
//
Macro begins here -
//
Purpose: Add an attribute (here, italics) to all
words found
// in a source list of words (a plain text ANSI or
ASCII file),
// wherever they are found in the current document.
//
See Instructions, Notes, and Tips above.
// Set the drive,
path and filename of
the external "source list" (text file) -
vFN:="c:\temp\sourcewords.txt"
// Set the type of attribute
to apply -
// 0=ExtraLarge; 1=VeryLarge; 2=Large; 3=Small; 4=Fine;
// 5=Superscript; 6=Subscript; 7=Outline; 8=Italics; 9=Shadow;
// 10=Redline; 11=DoubleUnderline; 12=Bold; 13=Strikeout;
// 14=Underline; 15=SmallCaps
vAttr:=8
FileExists(x;vFN)
If(x=False)
Messagebox(;"Error - File not found!";vFN+NToC(0F90Ah)+"cannot be
found.")
Quit
Endif
pResetFindReplace ()
// This snippet was
posted by Kenneth Hobson on WordPerfect Universe at
// http://www.wpuniverse.com/vb/showthread.php?postid=146096#post146096
Array[]=FileToArray(vFN)
// This snippet is
modeled after code posted by Greg Turner -
ForEach(vVar;Array[])
vLen:=StrLen(vVar)
If(vLen>79)
Messagebox(;"Caution"; "The item"+NToC(0F90Ah)+vVar+NToC(0F90Ah)+"is
too long and will be skipped.")
Go(Cont@)
Endif
PosDocVeryTop()
SearchString (StrgToLookFor: vVar)
ReplaceString (RplcStrg: vVar)
ReplaceWithAttributes (State: Yes!; Attribute: vAttr)
SearchCaseSensitive (State: Yes!) // (or use No!)
SearchFindWholeWordsOnly (State: Yes!) // (or use No!)
ReplaceForward (SearchMode: Extended!)
Label(Cont@)
Endfor
// Exit macro here -
pResetFindReplace ()
Return // (exit here)
// PROCEDURES AND
FUNCTIONS HERE:
// Function by
Kenneth Hobson -
//Read File into array and return array -
Function FileToArray(vFile)
hFile=OpenFile (vFile; Read!; Compatibility!; AnsiText!)
If (hFile=OpenFile.Error!)
MessageBox (;"Open File Problem"; "Error processing password '^0'
file!"; IconStop!+HasParameters!; vFile)
Quit
EndIf
Count=0
While (not FileIsEOF (hFile))
Count = Count+1
FileRead (hFile; x)
EndWhile
FilePosition(hFile; 0; FromBeginning!)
Declare TempArray[Count]
x=0
While (not FileIsEOF (hFile))
x=x+1
FileRead (hFile; TempArray[x])
EndWhile
CloseFile (hFile)
Return(TempArray[])
EndFunc
Procedure
pResetFindReplace ()
SearchString ("")
ReplaceString ("")
// Only one of these 4 Match commands can be active at any one time:
// MatchPositionAfter ()
// MatchExtendSelection()
// MatchPositionBefore()
MatchSelection()
SearchFindWholeWordsOnly (No!)
MatchWithAttributes (No!)
ReplaceWithAttributes (No!)
SearchCaseSensitive (No!)
ReplaceWithCase (No!)
MatchWithFont (No!)
ReplaceWithFont (No!)
MatchWithFontSize (No!)
ReplaceWithFontSize (No!)
SearchInSelection (No!)
SearchWordForms (No!)
SearchWrap (No!)
MatchLimit (No!)
EndProcedure
//
Macro ends
|
Footnote
2
Here is a simple version (original created by Greg Turner) of
the macro in Footnote 1 for those who want to write a
code snippet "on the fly" to do a simple job: Add an attribute (e.g.,
italics) to several different words wherever they are found in a
document. (See Tips below for other attributes.)
Instructions
- Enter each word you want
to process in your document on a separate line in the Array[] command
below. With each word/phrase on its own line in the Array[] command,
the list can be selected and sorted alphabetically, if desired, to make
it easier to maintain and update. [For a macro that can do the same job
as REPLACEM above -- but with a find/replace list created inside
the macro code rather than in a separate document -- see Footnote 3.]
- Be sure to replace the
sample 6 words ("Agreement," etc.) inside the Array[] with those words
you need to process.
- Be sure the last item
does not end with a semicolon (see the example in
the macro below). If it does, the macro will pop up an error message.
Notes
- The words (or phrases)
should not be longer than 79 characters each, including spaces, but
excluding the pair of double quote marks (which are required).
- You can search for words
using the Case Sensitive option by enabling that command below by
removing the pair of slash (//) marks preceding the SearchCaseSensitive
command. For example, if you enable that command and use the
Capitalized version of of the word "Agreement" in the Array command,
the macro will skip over any lover case version of the word (i.e.,
"agreement"). If you need both upper- and
lower-case versions of a word italicized, enter both versions in the
Array command (each version on its own line).
Tips
- To copy the macro code
into WordPerfect, see here
for instructions.
- Always test the effects
of the macro on a copy of your document (or a section of your document)
to see how it works.
- You can modify the macro
to produce other attributes (bold, large, small caps, etc.) Simply
replace the parameter, Italics!) in the ReplaceWithAttributes command
with any of the following: Bold!, Underline!, DoubleUnderline!,
ExtraLarge, VeryLarge!, Large!, Small!, Fine!, SmallCaps!, Redline!,
Subscript!, or Superscript!. However, UPPPER and lower case are not
"attributes," so they require special treatment; see the alternative
macro below (but which does not process headers, footers, footnotes, endnotes, text boxes, or
other WordPerfect "substructures").
- Once the words are
processed, you can instantly delete the attributes, add additional
attributes, or change attributes with Ron Hirsch's REPLACE CODES macro
here.
Example
macro to add italics
to various words, using a list embedded in the macro
|
//
Macro begins
//
Purpose: Add an attribute (here, italics) to all
words found
// in a source list of words embedded in the macro itself,
// wherever they exist in the document.
//
See Instructions, Notes, and Tips above.
Array[]={
"Agreement";
"Assignment";
"Leased Premises";
"Master Lease";
"Transferor";
"Transferee"
}
ForEach (vVar;Array[])
PosDocVeryTop()
SearchString (StrgToLookFor: vVar)
ReplaceString (RplcStrg: vVar)
ReplaceWithAttributes (State: Yes!; Attribute: Italics!)
//SearchCaseSensitive (State: Yes!) //
(see Notes above)
ReplaceForward (SearchMode: Extended!)
Endfor
Return // (exit here)
//
Macro ends
|
Example
macro to convert various
words to UPPER case, using a list embedded in the macro
|
//
Macro begins
//
Purpose: Convert all words to UPPER case that are found
// in a source list of words embedded in the macro itself,
// wherever they exist in the body text area of the document.
// (Additional code would be required to process substructures
// such as headers, footers, footnotes, endnotes, and text boxes.)
//
See Instructions, Notes, and Tips above.
//
For lower case or Initial Caps:
// Replace the ConvertUpperCase command to ConvertLowerCase or ConvertCaseInitialCaps
Array[]={
"Agreement";
"Assignment";
"Leased Premises";
"Master Lease";
"Transferor";
"Transferee"
}
OnNotFound(NextOne@)
MatchSelection
ForEach (vVar;Array[])
PosDocVeryTop()
SearchString (StrgToLookFor: vVar)
SearchNext (SearchMode: Regular!)
ConvertCaseUppercase
SelectMode(Off!)
Label(NextOne@)
//SearchCaseSensitive (State: Yes!) //
(see Notes above)
Endfor
Return // (exit here)
//
Macro ends
|
Footnote
3
Here is a macro posted by
Roy "lemoto" Lewis on WordPerfect Universe (4/16/08, and modified
slightly here) that finds each word/phrase in a list and replaces it with another word/phrase. For
example:
...replace "first" with
"second"
...replace "his" with "her"
...replace "this" with "that"
Instructions
- Enter each pair
of words or other items you want to process in your document on a separate line in the
Array[] command below. With each pair of items on its own line
in the Array[] command, the list can be selected and sorted
alphabetically, if desired, to make it easier to maintain and update.
- Be sure to replace the
sample pairs of items ({"first; second"}, etc.) inside the Array[] with
those items you need to process.
- Be sure the last item
does not end with a semicolon (see the example in
the macro below). If it does, the macro will pop up an error message.
Notes
- Unlike REPLACEM above,
this macro does not use a separate list (external file); rather, it
uses a simple 2-dimension array to store the find/replace pairs.
Therefore, you need to edit the macro and change the array to
list your particular items. In other words, be sure to
REPLACE the sample 3 pairs (in dark red)
inside the Array[] with those words you need to process. Also be sure
the last item does NOT end with a semicolon.
- As a matter of
interest to those curious about the third parameter in the ForNext
command below (i.e., Array[0]/2 ), this simply takes the number of
items (elements) in the array (which is stored in [0]) and divides it
by 2 to determine the total number of word pairs
to process. The ForNext loop then executes that
particular number of times. In the example below, with six items in the
array, ForNext executes three times, one time for each pair of items.
- Keep all words and
phrases in the source word file to less than 79 characters
per item, including spaces. (An "item" in this context is an
element in the array; here, there are two elements per find/replace
operation.) This is a limit of the macro language's SearchString()
command. While longer items can be written and stored into the macro's Array[]
command, only the first 79 characters/spaces of a matching item will be
processed.
- The macro processes the
document from the current cursor location onward by
setting a simple bookmark at that location and returning to it later.
You could remove the four existing (dark blue) Bookmark commands and add the command,
PosDocVeryTop, at both the beginning of the macro and again just after
the ReplaceForward command. [For a sample macro that processes just within a block of pre-selected text, see Footnote 4 below.]
- As
written, the macro will ignore headers, footers, footnotes, endnotes,
text boxes, and other "substructures." But these could be selected
individually before playing the macro on each of them.
- Finally, note the three
search qualifiers that precede the actual search and replace commands:
SearchCaseSensitive
(Yes!)
ReplaceWithCase(Yes!)
SearchFindWholeWordsOnly (Yes!)
[You may want to remove
one or more of these to suit your own find/replace requirements. The
default values are set at the top of the code with a Procedure.]
Tips
- To copy the macro code
into WordPerfect, see here
for instructions.
- Always test the effects
of the macro on a copy of your document to see how it works.
Example
macro
|
//
Macro begins
//
See Instructions, Notes, and Tips above.
pResetFindReplace ()
Prompt
("Replacing";"Please wait"; NoButtons!| InformationIcon!)
/* IMPORTANT:
Enter your own find-and-replace pairs below, following the pattern of
the first 3 items;
note that the last item does not
terminate with a semicolon, just a right brace;
note that each item (element) in a pair
should not exceed 79 characters (including spaces);
when finished entering your own list, delete the first 3 "sample" items.
Note also that
ReplaceForward(Regular!) does not search inside headers, footers,
watermarks,
footnotes, endnotes, text boxes. To search in them, use
ReplaceForward(Extended!).
*/
Array[]={
{"first";"second"};
{"his";"her"};
{"this";"that"}
}
SearchCaseSensitive
(Yes!)
ReplaceWithCase(Yes!)
SearchFindWholeWordsOnly (Yes!)
BookmarkCreate("cursor_location")
// (see Notes above)
ForNext(i;1;Array[0]/2)
PosDocVeryTop
SearchString (Array[i;1]) // (search for the first element in the pair)
ReplaceString (Array[i;2]) // (replace with the second element in the
pair)
ReplaceForward (Regular!)
BookmarkFind("cursor_location")
// (see Notes above)
EndFor
// Return Find and
Replace parameters to defaults:
pResetFindReplace ()
// Return to original
cursor location:
BookmarkFind("cursor_location")
// (see Notes above)
BookmarkDelete("cursor_location") // (see Notes above)
EndPrompt
Return // (exit here)
Procedure
pResetFindReplace ()
SearchString ("")
ReplaceString ("")
// Only one of these 4 Match commands can be active at any one time:
// MatchPositionAfter ()
// MatchExtendSelection()
// MatchPositionBefore()
MatchSelection()
SearchFindWholeWordsOnly (No!)
MatchWithAttributes (No!)
ReplaceWithAttributes (No!)
SearchCaseSensitive (No!)
ReplaceWithCase (No!)
MatchWithFont (No!)
ReplaceWithFont (No!)
MatchWithFontSize (No!)
ReplaceWithFontSize (No!)
SearchInSelection (No!)
SearchWordForms (No!)
SearchWrap (No!)
MatchLimit (No!)
EndProcedure
//
Macro ends
|
Footnote 4 Here is a variation of the macro example in Footnote 3 above.
Instead of processing the document from the cursor location onward, it processes only within a block of pre-selected text.
Instructions
- Enter each pair
of words or other items you want to process in your document on a separate line in the
Array[] command below. With each pair of items on its own line
in the Array[] command, the list can be selected and sorted
alphabetically, if desired, to make it easier to maintain and update.
- Be sure to replace the
sample pairs of items ({"first; second"}, etc.) inside the Array[] with
those items you need to process.
- Be sure the last item
does not end with a semicolon (see the example in
the macro below). If it does, the macro will pop up an error message.
Notes
- Unlike REPLACEM above,
this macro does not use a separate list (external file); rather, it
uses a simple 2-dimension array to store the find/replace pairs.
Therefore, you need to edit the macro and change the array to
list your particular items. In other words, be sure to
REPLACE the sample 3 pairs (in dark red)
inside the Array[] with those words you need to process. Also be sure
the last item does NOT end with a semicolon.
- As a matter of
interest to those curious about the third parameter in the ForNext
command below (i.e., Array[0]/2 ), this simply takes the number of
items (elements) in the array (which is stored in [0]) and divides it
by 2 to determine the total number of word pairs
to process. The ForNext loop then executes that
particular number of times. In the example below, with six items in the
array, ForNext executes three times, one time for each pair of items.
- Keep all words and
phrases in the source word file to less than 79 characters
per item, including spaces. (An "item" in this context is an
element in the array; here, there are two elements per find/replace
operation.) This is a limit of the macro language's SearchString()
command. While longer items can be written and stored into the macro's Array[]
command, only the first 79 characters/spaces of a matching item will be
processed.
- The macro processes all items found in the
currently selected text by
setting simple paired bookmark commands (shown in blue) to allow the macro to easily re-select the selection with each pass. [For a sample macro that processes from the current cursor location to the end of the document, see Footnote 3 above.]
- As
written, the macro will ignore headers, footers, footnotes, endnotes,
text boxes, and other "substructures." But these could be selected
individually before playing the macro on each of them.
- Finally, note these three
search qualifiers that precede the actual search and replace commands:
SearchCaseSensitive
(Yes!)
ReplaceWithCase(Yes!)
SearchFindWholeWordsOnly (Yes!)
[You may want to remove
one or more of these to suit your own find/replace requirements. The
default values are set at the top of the code with a Procedure.]
Tips
- To copy the macro code
into WordPerfect, see here
for instructions.
- Always test the effects
of the macro on a copy of your document to see how it works.
Example
macro
|
//
Macro begins
//
See Instructions, Notes, and Tips above.
pResetFindReplace ()
// Create a paired bookmark around the selection of text, then select it again: BookmarkCreate("current_selection") BookmarkBlock("current_selection")
/* IMPORTANT:
Enter your own find-and-replace pairs below, following the pattern of
the first 3 items;
note that the last item does not
terminate with a semicolon, just a right brace;
note that each item (element) in a pair
should not exceed 79 characters (including spaces);
when finished entering your own list, delete the first 3 "sample" items.
Note also that
ReplaceForward(Regular!) does not search inside headers, footers,
watermarks,
footnotes, endnotes, text boxes. To search in them, use
ReplaceForward(Extended!).
*/
Array[]={
{"first";"second"};
{"his";"her"};
{"this";"that"}
}
SearchCaseSensitive
(Yes!) // (optional: See Notes above)
ReplaceWithCase(Yes!) // (optional: See Notes above)
SearchFindWholeWordsOnly (Yes!) // (optional: See Notes above) SearchInSelection(Yes!) // (required: search only inside currently selected block)
ForNext(i;1;Array[0]/2)
PosBlockTop // (not really needed here, but useful with some other ForNext loops)
SearchString (Array[i;1]) // (search for the first element in the pair)
ReplaceString (Array[i;2]) // (replace with the second element in the
pair)
ReplaceForward (Regular!) // (execute the replacements)
BookmarkBlock("current_selection") // (re-select the selection)
EndFor
// Return Find and
Replace parameters to defaults:
pResetFindReplace ()
// The next 2 commands to position curosr and remove select mode are OPTIONAL: PosBlockBottom SelectMode(Off!) // Clean up: Remove bookmark code: BookmarkDelete("current_selection")
// Edit macro: Return
Procedure
pResetFindReplace ()
SearchString ("")
ReplaceString ("")
// Only one of these 4 Match commands can be active at any one time:
// MatchPositionAfter ()
// MatchExtendSelection()
// MatchPositionBefore()
MatchSelection()
SearchFindWholeWordsOnly (No!)
MatchWithAttributes (No!)
ReplaceWithAttributes (No!)
SearchCaseSensitive (No!)
ReplaceWithCase (No!)
MatchWithFont (No!)
ReplaceWithFont (No!)
MatchWithFontSize (No!)
ReplaceWithFontSize (No!)
SearchInSelection (No!)
SearchWordForms (No!)
SearchWrap (No!)
MatchLimit (No!)
EndProcedure
//
Macro ends
|
|