Define Macro [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation
HP EDIT Reference Manual
Define Macro
Purpose
Defines a macro using a line of text.
Default Syntax
z
Description
This command enables you to define a macro that you have created on a
line within a file. The command provides a manual approach for defining
macros, whereas the Begin Capture and Capture Macro commands provide an
automated, interactive approach for defining macros.
Command Process
In order for this command to function, you first construct the macro
using proper macro syntax on a separate line within your file. You then
execute the command. HP EDIT responds by deleting the macro from the
screen and storing it for subsequent execution. You could then use
either the Execute Macro command or the Go To Macro command to execute
the macro.
Saving Defined Macros
Note that a newly defined macro only exists for the current session
process. The macro is not executable within other active child or parent
processes during the current session. In order to use the macro in other
processes or in subsequent sessions, you must first define the macro and
then save it to a configuration file using the Save Config File command.
You could either save the macro to the EDCONFIG default configuration
file or to another file name. You would then read in the configuration
file using the Load Config File command for subsequent sessions or other
processes.
Restrictions
You cannot use the following keys as preemptive macro names because HP
EDIT reserves them for internal use:
[REV BEG]
^f ^k ^u ^w ^y ^g ^/ ^] ^_
[REV END]
Macro Syntax
In order to properly define a macro, you must use the correct syntax
components in the proper sequence as indicated:
1. Macro Initiator
Type the letter m in the first column of a line to indicate
that a macro definition follows:
m
2. Macro Name
This consists of the single key or prefixed key assigned to
the macro that is to be used to subsequently execute the
macro. The prefixed key is indicated with a dollar sign
($) following the assigned key. A control key is indicated
by a caret (^) preceding the assigned key.
You can automatically execute a macro whenever an editing
session begins by naming it ^@ and saving it to the default
EDCONFIG file. The macro ^@ is known as the Autostart
macro.
Type the macro name, such as S, after the macro initiator:
mS
3. Preemptive Indicator
This character determines whether the key assigned to the
macro (the macro name) preempts the function of the same
key assigned to an HP EDIT command. For instance, the S
key is ordinarily assigned to the Scroll Backward command.
If you assign the S macro as preemptive, HP EDIT executes
the macro rather than executing the Scroll Backward
command.
If you assign the S macro as non-preemptive, HP EDIT does
not automatically execute the macro. You must execute the
macro by using either the Execute Macro or Go To Macro
command. You make a macro preemptive by typing a colon (:)
after the macro name. You make a macro non-preemptive by
typing an equals sign (=) after the macro name:
mS=
4. Macro Text
Type the macro text following the preemptive indicator.
For instance, if you want to insert the word end before the
current line, type the text shown after the non-preemptive
indicator:
mS=Iend;/^m
Note that ^m represents the Return key.
5. Optional Comments
You may optionally add comments or preserve blanks in a
macro by appending the Quit Macro command. The command
functions as a separator between the macro and the
comments. The command instructs HP EDIT to ignore text
that follows the letter Q when it executes the macro. Type
the letter Q and the desired comments after the macro
terminator:
mS=Iend;/^mQ *** This macro inserts "end".
Procedure
To define a macro from text:
1. Insert a new line in text by executing the Insert Line (I)
command.
2. Type in a macro beginning at the cursor position at the far left
column, using the appropriate macro syntax discussed in the last
section.
3. Press / and Return to exit Text Entry mode and enter Command mode.
4. Press the z key. HP EDIT deletes the macro definition from the
screen and stores it for subsequent execution. HP EDIT also
displays Macro defined on the message line.
Examples
To define a non-preemptive macro named ^b that finds the next blank line:
1. Insert a new line in text by executing the Insert Line (I)
command.
2. Type the following macro beginning at the start of the line:
m^b=f^^ *$^m/
[REV BEG]
Note that the ^^ in the example above indicates the use of a
single caret within a macro.[REV END]
3. Press / and Return to exit Text Entry mode and enter Command mode.
4. Press the z key. HP EDIT deletes the macro from the screen and
stores it for subsequent execution. HP EDIT also displays the
following message:
Macro defined
To define a preemptive macro named K that keeps text and then exits HP
EDIT:
1. Insert a new line in text by executing the Insert Line (I)
command.
2. Type the following macro beginning at the start of the line:
mK:k^me
3. Press / and Return to exit Text Entry mode and enter Command mode.
4. Press the z key. HP EDIT deletes the macro from the screen and
stores it for subsequent execution. HP EDIT also displays the
following message:
Macro defined
To define a non-preemptive macro named B that appends Begin: to the end
of a line:
1. Insert a new line in text by executing the Insert Line (I)
command.
2. Type the following macro beginning at the start of the line:
mB=; Begin:/^m
3. Press / and Return to exit Text Entry mode and enter Command mode.
4. Press the z key. HP EDIT deletes the macro from the screen and
stores it for subsequent execution. HP EDIT also displays the
following message:
Macro defined
To define a non-preemptive macro named E that inserts end; before the
current line:
1. Insert a new line in text by executing the Insert Line (I)
command.
2. Type the following macro beginning at the start of the line:
mE=Iend;/^mQ ** This macro inserts end; before a line.
3. Press / and Return to exit Text Entry mode and enter Command mode.
4. Press the z key. HP EDIT deletes the macro from the screen and
stores it for subsequent execution. HP EDIT also displays the
following message:
Macro defined
Related Commands
Begin Capture
Capture Macro
Define Multiple Macros
Delete All Macros
Delete Macro
Execute Macro
Go To Macro
Insert All Macros
Insert Macro
Quit Macro
Show Macros
Use Current Key Assignment
MPE/iX 5.0 Documentation