HP 3000 Manuals

Use X Register [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation


HP EDIT Reference Manual

Use X Register 

Purpose 

Sets or retrieves the X register.

Default Syntax 

[n] $x

where n represents a count that, if specified, moves to the X register.

Description 

This command enables you to pass integers to and from macros and the HP
EDIT calculator X register.  The X register resides at the top of a
four-register computational stack accessible through the Calculate
command.

Specifying A Count 

If you specify a count before executing this command, the value is saved
in the X register, replacing the previous value.  If you do not specify a
count, HP EDIT places the current value of the X register into the count
for use by the next command.

Ordinarily, if you specify a count before executing a macro, the macro
repeats the number of times specified.  However, if the Use X Register
command is the first command executed within the macro, the specified
count is loaded into the X register and the macro executes only once.
This process enables you to use the X register to pass a parameter (the
count) to a macro.
[REV DEL]

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.

Since the standard Meta key (ESC) is displayed as ^[ when inserted in a
macro, HP EDIT provides the dollar sign ($) as an alternate Meta key.
Consequently, you should use the recommended syntax of $x within a macro.

Procedure 

To place a value in the X register: 

   1.  Type a count representing the value desired.

   2.  Press ESC and the x key.  HP EDIT stores the value in the X
       register.

To retrieve the X register value: 

   1.  Press ESC and the x key.  HP EDIT displays the value of the X
       register as a count on the message line.

Examples 

To interactively delete the next n lines, where n represents the current 
X register value: 

   1.  Press ESC and the x key.  HP EDIT displays the value of the X
       register as the count on the message line.

   2.  Execute the Delete Line (D) command.  HP EDIT deletes the number
       of lines displayed as the count.

To define and execute a macro that shifts the current line the number of 
spaces specified in the count: 

   1.  Execute the Insert Line (L) command to insert a new line and enter
       Text Entry mode.

   2.  Type the following macro, which saves the macro count in the X
       register, invokes the calculator, stores the count into the shift
       count, exits the calculator, and finally executes a shift to the
       right:

            m>=$x$+s>^m>

   3.  Exit Text Entry mode by pressing / and Return.

   4.  Define the macro using the Define Macro (z) command.  HP EDIT
       deletes the macro from the screen and displaying the following
       message:

            1 macro defined

   5.  Type the number 5 as the count.

   6.  Execute the macro using the Execute Macro (m) command.  When
       prompted for the command name, type >.  HP EDIT shifts the current
       line 5 spaces to the right.  Note that this shift count remains
       for subsequent shift commands until you change it or leave the
       session.

Related Commands 

       Calculate
       Use Y Register



MPE/iX 5.0 Documentation