HP 3000 Manuals

Macros [ System Debug Reference Manual ] MPE/iX 5.0 Documentation


System Debug Reference Manual

Macros 

System Debug supports an extensive macro facility that allows users to
define a sequence of commands that may be invoked either as a command or
as a function in an expression.  The MAC command is used to define a
macro, as the following examples illustrate:

     $nmdebug > mac double (n=2) { return n * 2 } 
     $nmdebug > mac formattable (entry=1) {...} 

Reference to macros as functions in expressions look exactly like
references to predefined functions:

     $nmdebug > wl double (1) 
     $2
     $nmdebug > wl double (double (1)) 
     $4
     $nmdebug >

Macro parameters may be defined as being either required or optional (as
indicated by the presence of default parameter values in the macro
definition).  When all of a macro's parameters are optional and it is
referenced as a function without any parameters, the enclosing
parentheses are optional:

     $nmdebug > wl double () 
     $2
     $nmdebug > wl double 
     $2
     $nmdebug >

When macros are used as commands, the parentheses surrounding the
parameters may be omitted:

     $nmdebug > formattable 3 
     ...
     $nmdebug > formattable (3) 
     ...

However, since macro command parameters may still be surrounded by
parentheses as an option, care must be used when the first parameter is
an expression that begins with a parenthesis of its own.  In this case,
the parenthesis is seen as the beginning of a parenthesized list of
command parameters, and not as belonging to the expression for the first
parameter.  Thus, parameters surrounding the entire command list are
required when the first parameter starts with a parenthesis:

     $nmdebug > formattable (current_entry + 1) * 2      /* wrong
     $nmdebug > formattable ((current_entry + 1) * 2)    /* right



MPE/iX 5.0 Documentation