HP 3000 Manuals

Replace Word From Macro [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation


HP EDIT Reference Manual

Replace Word From Macro 

Purpose 

Enables you to replace one or more words in text from an executing macro.

Default Syntax 

None

This command does not have a default key assignment.  You can either
assign a key to the command using the Assign Key command or issue the
command using Execute Editor Command.

Description 

This command, when used within a macro, suspends a currently executing
macro and enables you to substitute a word or words with other text.

When you execute a macro containing this command, HP EDIT deletes the
current word and places the editor in Text Entry mode, enabling you to
insert text.  You can optionally specify a count preceding the command if
you want to delete more than the default of one word before inserting
replacement text.

Command Process 

When the macro pauses for your input, HP EDIT displays the prompt Waiting 
for keyboard input on the message line.  You can then insert replacement
text.  All of the original text to the right of the replacement location
shifts to the right when you enter text.  If there is insufficient blank
space to add text or to fit the original text, HP EDIT wraps the excess
text onto the next line.

When you have finished substituting deleted words with replacement text,
pressing / and Return resumes execution of the macro.

Syntax Considerations 

In order to use this command within a macro, you must properly construct
the macro using correct syntax.  Refer to the Define Macro command for
information about required syntax.

This command differs from other related commands with key assignments in
that if you do not assign a key to this command, you must type the text
name of the command to execute it within a macro.  Since this command is
only useful within a macro, it is recommended that you assign a key to
the command to reduce the macro space it consumes.

Word Definition 

HP EDIT enables you to specify the type of characters that constitute an
HP EDIT word.  There are four possible word definitions.  You can specify
a definition other than the default value by changing the value of the
Word Category parameter from the Set Options screen.

The following word definition options are available:

[a-zA-Z0-9_'-]        Words consist of upper and lowercase letters,
                      digits, underscores, apostrophes, and hyphens.
                      Words are separated by spaces and any
                      non-alphanumeric characters besides the underscore,
                      apostrophe, or hyphen.  This is the default
                      definition.

[a-zA-Z0-9_]          Words consist of upper and lowercase letters,
                      digits and underscores.  Words are separated by
                      spaces and any non-alphanumeric characters besides
                      the underscore.

[a-zA-Z0-9]           Words consists of upper and lowercase letters as
                      well as digits.  Words are separated by spaces and
                      any non-alphanumeric characters.

[~ ]                  Words consist of any non-space characters separated
                      by spaces.

Procedure 

To execute this command within a macros: 

   1.  Construct the macro containing this command using proper macro
       syntax.  Refer to the Define Macro command for information about
       constructing macros.  Skip to Step 3 if this macro is preemptive
       (preempts the command to which the key is ordinarily assigned).

   2.  Execute the macro by pressing the m key.  HP EDIT displays Specify 
       macroname on the message line.

   3.  Type the macro name as specified in the macro.  HP EDIT executes
       the macro, deletes a word or words, and pauses for your input.

   4.  Provide the input and then press / and Return to return to Command
       mode.  HP EDIT resumes execution of the macro.

Example 

To construct, define, and execute a macro that pauses for you to replace 
the word NOT with the word NOW: 

   1.  Insert a new line in text by executing the Insert Line (I)
       command.

   2.  Type in the following macros beginning at the cursor position:

            mR=EReplace Word From ^m
            mr=AThis sentence is not/^mbmR; correct./^m

   3.  Press / and Return to exit Text Entry mode and enter Command mode.

   4.  Move the cursor to the first macro and execute the Define Multiple
       Macros (ESC z) command.  HP EDIT deletes the macros from the
       screen and stores them for subsequent execution.

   5.  Press the m key.  HP EDIT displays the following prompt on the
       message line:

            Specify macroname

   6.  Press the r key.  HP EDIT first inserts the following text:

            This sentence is not_

       HP EDIT then deletes the word not and pauses for your input.

   7.  Type the word now and then press / and Return.  HP EDIT completes
       the line as shown:

            This sentence is now correct.

Related Commands 

       Append Line From Macro
       Append To Character From Macro
       Append To End Of Line From Macro
       Define Replace Pattern From Macro
       Define Search Pattern From Macro
       Insert Character From Macro
       Insert Line From Macro
       Overwrite From Macro
       Replace Character From Macro
       Replace Line From Macro
       Replace Word



MPE/iX 5.0 Documentation