HP 3000 Manuals

Test/Set/Clear Flag [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation


HP EDIT Reference Manual

Test/Set/Clear Flag 

Purpose 

Tests, sets, clears, or complements the flag used in conditional macros.

Default Syntax 

[n] $t

where n represents the value of the flag.  There is no default value for
n.

Description 

This command, when used within a macro and not preceded by a count,
enables you to conditionally execute selected portions of macros,
depending on the value of a settable flag.  When executed in this manner,
the command is intended to be used in conjunction with the Terminate True
Clause command.  If given a count, however, the command modifies the
flag.

This command functions differently depending on whether you want to set,
clear, complement, or test the flag.

Setting The Flag 

To set the flag, which is equivalent to specifying a value of true, you
specify a count of 1 before executing the command.  If executed from the
keyboard rather than from within a macro, HP EDIT displays Flag set on
the message line.

Clearing The Flag 

To clear the flag, which is equivalent to specifying a value of false,
you specify a count of 2 before executing the command.  If executed from
the keyboard, HP EDIT displays Flag cleared on the message line.

Complementing The Flag 

To complement the flag, which is equivalent to specifying a value
opposite the current value, you specify a count greater than 2, such as
3, before executing the command.  If executed from the keyboard, HP EDIT
displays the flag value with Flag set or Flag cleared on the message
line.

Testing The Flag 

You can begin a set of conditional commands in a given macro by testing
the flag.  To test the flag in a macro, you execute the command without
specifying a count.  This action only has an effect within a macro.  If
the flag is true (set), commands within the macro continue to execute
normally.  If the flag is false (cleared), HP EDIT skips commands until
it encounters the Terminate True Clause command.

Other Methods of Modifying the Flag 

Search commands and search and replace commands modify the flag value.
Successful searches set the flag to true.  Failed searches, including
user-aborted searches, clear the flag to false.

You can also set the flag by using certain operators available with the
HP EDIT calculator.  Seven calculator operators can set, clear, or
complement the flag.  Refer to the Calculate command for further
information.

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 $t within a macro.

Conditional Macro Components 

A conditional macro may consist of the following components:

   1.  Initial section consisting of the macro initiator, macro name,
       preemptive status, and macro text:

            mZ=IAll employees/^m

   2.  Conditional section consisting of the Test/Set/Clear Flag command,
       conditional text, and the Terminate True Clause command:

            mZ=IAll employees/^m$t; over 40/^m$T

   3.  Final section consisting of text:

            mZ=IAll employees/^m$t; over 40/^m$T; must respond./^m

If you were to execute the macro example shown above, HP EDIT would
either:

   *   Insert the text All employees over 40 must respond into your file
       if the flag is set (true),

            or 

   *   Insert the text All employees must respond into your file if the
       flag is cleared (false).

Note that more than one conditional section can exist in a conditional
macro.

Procedures 

To set the flag: 

   1.  Type 1 ESC t at the keyboard .  HP EDIT displays Flag set on the
       message line.

            or 

   2.  Insert 1$t in a macro where you want to set the flag.

To clear the flag: 

   1.  Type 2 ESC t at the keyboard .  HP EDIT displays Flag cleared on
       the message line.

            or 

   2.  Insert 2$t in a macro where you want to set the flag.

To complement the flag: 

   1.  Type 3 or any count greater than 2, then type ESC t from the
       keyboard.  HP EDIT displays Flag set or Flag cleared on the
       message line, depending on the new value of the flag.

            or 

   2.  Insert 3$t in a macro where you want to switch the flag value.

To test the flag: 

   1.  Construct a macro containing a conditional section initiated with
       $t and terminated with $T.

   2.  Execute the macro using either the Execute Macro (m) command or
       the Go To Macro (M) command.  HP EDIT executes the entire macro if
       the value of the flag is true, and executes the macro without the
       conditional section if the flag is false.

Examples 

To construct, define, and execute a conditional macros: 

   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:

            mz=3+$t2D+$T5+

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

   4.  Execute the Define Macro (z) command.  HP EDIT deletes the macro
       from the screen and stores it for subsequent execution.

   5.  Issue the Execute Macro (m) command.  HP EDIT displays the
       following prompt on the message line:

            Specify macroname

   6.  Press the z key.  HP EDIT moves the cursor down three lines and
       tests the flag when it encounters the imbedded Test/Set/Clear Flag
       command.  If the flag is true, HP EDIT:

          *   Deletes two lines

          *   Moves the cursor down another line

          *   Ends the conditional clause because it encounters the
              Terminate True Clause command

          *   Moves the cursor down five lines

       If the flag is false, HP EDIT:

          *   Skips executing commands until encountering the Terminate
              True Clause command

          *   Moves the cursor down five lines

To construct and execute a macro that shows whether the flag is set using 
the complement feature: 

   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:

            mf=IFlag is /^m3$t$tanot /^m$Taset/^m3$t+

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

   4.  Execute the Define Macro (z) command.  HP EDIT deletes the macro
       from the screen and stores it for subsequent execution.

   5.  Issue the Execute Macro (m) command.  HP EDIT displays the
       following prompt on the message line:

            Specify macroname

   6.  Press the f key.  HP EDIT tests the flag and inserts the text Flag 
       is set into your file.  This indicates that the value of the flag
       is true.  If you want to change the value to false (clear the
       flag), proceed to step 7.

   7.  Type the number 2 as the count and execute the Test/Set/Clear Flag
       command at the keyboard level by pressing ESC and the t keys.  HP
       EDIT displays the message Flag cleared on the message line.

   8.  Issue the Execute Macro (m) command.  HP EDIT displays the prompt
       Specify macroname on the message line.

   9.  Press the f key.  HP EDIT tests the flag and inserts the text Flag 
       is not set into your file.  The false value remains until you
       specify another value at either the keyboard level or within the
       macro.

Related Commands 

       Terminate True Clause
       Test And Execute Macro
       Test And Go To Macro



MPE/iX 5.0 Documentation