Q39998: Search and Replace Macro for M Editor
Article: Q39998
Product(s): See article
Version(s): 1.00 | 1.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_basic
Last Modified: 12-JAN-1989
Question:
Can you write a macro to perform a search and replace on a particular
string? When I try to do so, the replace function prompts me for a
string argument. I want the replace function to read the string from
the macro.
Response:
The following is an example of a replace macro that accepts its
argument from inside the macro:
myreplace:=replace "oldtext" newline "newtext" newline
When the myreplace macro is invoked, all the occurrences of "oldtext"
string, from the cursor position to the end of the file, are replaced
with the "newtext" string. The use of the newline function allows the
macro to respond to the replace-function prompt for a string argument.
To define the myreplace macro and assign it to the F12 key, enter the
following keystrokes from inside the M editor:
ALT+A
MyReplace:=replace "oldtext" newline "newtext" newline
ALT+=
ALT+A
MyReplace:F12
To execute the myreplace macro, press the F12 key.
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.