Macro Commands [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation
HP EDIT Reference Manual
Macro Commands
Macros enable you to perform tasks that would ordinarily require several
separate operations. The complexity of macros you can create varies
widely, ranging from scrolling text to performing mathematical
computations.
HP EDIT provides basic macro commands to meet your general requirements,
such as defining and executing macros. In addition, HP EDIT also
features specialized commands for use within macros, in which you can
provide text input from the keyboard during macro execution. Other
commands conditionally execute selected portions of macros or invoke the
HP EDIT calculator.
Execution And Management
These commands constitute the fundamental macro command set. They can be
executed from the keyboard like any other HP EDIT command, although the
Quit Macro command has no effect at the keyboard other than clearing the
count. The primary function of these commands is to enable you to
construct and execute macros. Execution and management macro functions
and associated commands are:
* Defining macros
Begin Capture
Capture Macro
Define Macro
Define Multiple Macros
* Executing macros
Execute Macro
Go To Macro
* Displaying macros
Show Macros
* Editing macros
Insert Macro
Insert All Macros
* Deleting macros
Delete Macro
Delete All Macros
* Suppressing macros
Use Current Key Assignment
* Using special functions
Display Message
Delay
Quit Macro
Defining Macros.
You can either define a macro interactively or manually. If you define a
macro interactively, HP EDIT prompts you for the information it needs to
create a macro. This simplified method constitutes the standard,
preferred method of creating a macro. You can also manually define a
macro from text if you would rather provide all of the required macro
syntax as well as the text.
You can define a macro interactively using the Begin Capture and Capture
Macro commands. You execute the Begin Capture command, then indicate the
tasks you want the macro to perform. HP EDIT records your keystrokes as
you execute them. When you want to stop recording, you execute the
Capture Macro command. This command retrieves all of the keystrokes
typed after you executed the Begin Capture command and transforms your
keyed text into a macro by prompting for information to describe the
macro.
You can alternatively use the Capture File command to record keyboard
input. This command, like the Capture Macro command, is first initiated
by executing the Begin Capture command. However, the two commands serve
entirely different functions. When you execute the Capture File command,
HP EDIT prompts you for the name of the file to which you want to save
your input. Consequently, instead of creating and defining macros, the
Capture File command enables you to record any or all session input for
future reference or debugging.
You can use the Define Macro command or Define Multiple Macros command to
manually define one or more macros. You define a single macro by
constructing the macro on a separate line of text and then executing the
Define Macro command. The macro must adhere to correct syntax as
described in the reference module for this command located in chapter 4.
To define more than one macro, it is more efficient to use the Define
Multiple Macros command. By placing the cursor at the first macro of the
group to be defined, HP EDIT defines all of the macros in the group when
you execute the command.
Executing Macros.
If you have defined a preemptive macro, you can execute it directly by
typing its command name, which is the key you assigned to the macro. If
you have defined a non-preemptive macro, however, you must execute it
using either the Execute Macro command or Go To Macro command. The
command you choose depends on the type of macro you want to execute.
(Refer to the Define Macro command in chapter 4 for the definition of a
preemptive and non-preemptive macro.)
These commands function differently only when they are executed from
within a macro. If you execute them from the keyboard as standalone
commands, the Go To Macro command functions the same as the Execute Macro
command.
If you want to execute a macro that returns to the current input level
after execution, you should use the Execute Macro command. This command
is also recommended when you want to execute a macro that consists of a
group of nested macros. If you want to execute a macro on the current
input level, you should use the Go To Macro command. This command is
suggested when you want to execute a chained macro, which is a macro
defined as several macros in order to overcome line length limitations.
To construct chained or nested macros, you use the appropriate command
within each macro of the nested or chained sequence.
Displaying Macros.
To display all currently defined macros, you can execute the Show Macros
command. This command suspends the editing session and displays a screen
that shows all macro names (keys assigned to the macro), preemptive
status, and macro text. Macro comments, if any, are also shown.
Editing Macros.
To edit an existing macro, use the Insert Macro command. When you
execute the command, HP EDIT inserts the macro into your text where you
can edit it as desired. You can then redefine the edited macro using the
Define Macro command. If you want to edit more than one macro, use the
Insert All Macros command. After you have edited the macros, you can use
the Define Multiple Macros command to redefine all of the edited macros
simultaneously.
The insert commands only insert macros defined during the current session
or macros that have been read in from a configuration file prior to
command execution. These commands cannot insert macros from
configuration files that have not been read in during the current
session.
Deleting Macros.
HP EDIT provides two commands for deleting one or all macros. To delete
a single macro, you can execute the Delete Macro command and specify the
name of the macro you want to delete. If you want to delete all
currently defined macros, you can execute the Delete All Macros command.
These commands only delete macros that exist in the current session. To
permanently delete macros from a configuration file, you can overwrite
the configuration file with the current environment using the Save Config
File command after deleting the unwanted macros from the environment.
Suppressing Macros.
If you define a preemptive macro and press the key assigned to the macro
(the macro name), the macro automatically executes. However, the key
assigned to a preemptive macro may also be assigned to an HP EDIT
command. In order to execute the command instead of the macro, you would
execute the Use Current Key Assignment command. This command instructs
HP EDIT to interpret the next key you press as assigned to a command,
rather than a preemptive macro.
Using Special Functions.
HP EDIT provides a special command for displaying messages within macros.
When your macro executes the Display Message command, a message appears
on the message line. If the message does not remain for a sufficient
length of time, you can lengthen the time the message is displayed by
imbedding the Delay command.
You can use the Delay command for other functions besides lengthening the
time a message is displayed. For instance, you could construct a macro
that scrolls forward, displays the screen (using the Refresh Screen
command), delays for several seconds, and then repeats the sequence
several times. This would simulate the effect of a slide show.
Whenever you want to add comments to a macro, you must terminate the
macro text by appending the Quit Macro command to the end of the macro.
This command informs HP EDIT that the text following the command consists
of comments rather than macro text.
Keyboard Input
Each of the commands that place the HP EDIT in Text Entry mode has a
corresponding command that can be used within macros. These commands
function similarly to the related text entry commands, except that the
keyboard input commands enable you to provide text input during the
execution of a macro. Two of these commands prompt you for either a
search or replace pattern, rather than place you in Text Entry mode.
When you execute a macro that contains one of these commands, HP EDIT
executes the macro until it encounters the command. Depending on the
type of command it encounters, HP EDIT either suspends execution of the
macro and enters Text Entry mode, or it prompts you to provide a search
or replace pattern. After you have either provided text input or
responded appropriately, HP EDIT resumes execution of the macro.
Keyboard input functions and associated commands are:
* Adding or changing text
Append To Character From Macro
Append To Word From Macro
Append Line From Macro
Append To End Of Line From Macro
Insert Character From Macro
Insert Line From Macro
Overwrite From Macro
Replace Character From Macro
Replace Word From Macro
Replace Line From Macro
* Defining search and replace patterns
Define Search Pattern From Macro
Define Replace Pattern From Macro
Adding Or Changing Text.
Whenever you want to add, insert, overwrite, or replace text from a
macro, you can use one of the appropriate text entry command variants
listed above.
When you execute a macro containing one of these commands, HP EDIT
executes the macro until it encounters the imbedded command. HP EDIT
then enters Text Entry mode, moves the cursor to the appropriate
location, and pauses for your input. After you provide the necessary
input, you press the / and Return keys to return to Command mode. HP
EDIT responds by resuming the macro execution.
Defining Search And Replace Patterns.
HP EDIT features two commands that function as variations of the standard
pattern definition commands. If you want HP EDIT to prompt you for a
search pattern or replacement string from a macro, you can use the Define
Search Pattern From Macro and/or Define Replace Pattern From Macro
commands to define search and replace patterns from the keyboard.
When you execute a macro containing one of these commands, HP EDIT
executes the macro until it encounters the imbedded command. HP EDIT
then prompts you for either the desired search pattern or the replacement
string. After you provide the necessary input and press the Return key,
HP EDIT responds by resuming the macro execution.
Conditional
Conditional commands enable you to conditionally execute selected
portions of macros, depending on the value of a settable flag. Like the
keyboard input macro commands, these commands are typically used within a
macro.
Conditional functions and associated commands are:
* Defining and terminating
Test/Set/Clear Flag
Terminate True Clause
* Testing and executing
Test And Execute Macro
Test And Go To Macro
Defining And Terminating.
In order to construct a conditional macro, you must decide which portion
of the macro you want to conditionally execute. You precede each
conditional section with the Test/Set/Clear Flag command. This command
serves four purposes, depending on the value of the flag and the
specified count. You can either set, clear, complement, or test the
flag.
You place the Terminate True Clause command at the end of each
conditional section. If the flag is set (true) when HP EDIT encounters
the conditional section, HP EDIT executes it. Otherwise, HP EDIT skips
the conditional section, which ends with the Terminate True Clause
command. The remainder of the macro then executes.
Testing And Executing.
If you want to test the flag and then immediately execute a specified
macro within a macro, you can use either the Test And Execute Macro
command or the Test And Go To Macro command. If HP EDIT encounters
either of these commands and the flag is true, then the specified macro
immediately following the command executes. If the flag is false, the
macro does not execute.
Like their unconditional macro counterparts, the Test And Execute Macro
command runs a macro as a subroutine, and the Test And Go To Macro
command runs a macro on the current input level.
Calculator
You can pass integer parameters to macros to increase their flexibility.
HP EDIT reserves the general-purpose X and Y registers for this purpose.
HP EDIT provides a calculator with which you can perform standard
mathematical calculations or manipulate the contents of these registers
and internal HP EDIT variables. The available calculator commands are:
Calculate
Use X Register
Use Y Register
You can access the HP EDIT calculator either interactively or
programatically. When you execute the Calculate command from the
keyboard, HP EDIT prompts you to specify the desired calculation. You
can enter as many calculator commands as you want to the end of the
message line. When you press Return, HP EDIT responds by displaying the
final values of the X and Y registers. To execute the Calculate command
programatically, you use the command within a macro that incorporates the
desired calculations.
The calculator uses a Reverse Polish Notation (RPN) Stack to perform
computations. The X register is at the top of the four-register, math
evaluation stack and the Y register is directly below it. The Z and T
registers are below the Y register. HP EDIT also provides ten additional
registers (0-9) that you can use for general storage.
You can use the Calculate command to access the value of HP EDIT
variables, such as the current line and column position, through the
store and recall operators. You can read certain variables and either
read or write to others.
You can execute the Use X Register command or the Use Y Register command
to transfer one of these registers into the count or to move the count
into one of these registers.
MPE/iX 5.0 Documentation