System Debug Reference Manual (32650-90888)

208 Chapter6
System Debug Command Specifications M-X
MAC[RO]
The macro is entered interactively across several lines. The unterminated left curly brace
causes the interpreter to enter
multi-line mode
. The prompt changes to indicate that the
interpreter is waiting for additional input. The nesting level, or depth of unterminated
curly braces, is displayed as part of the prompt.
The macro starline is called with the parameter 5, and a line of five stars is printed. The
macro is called again to print a line with sixty stars. In the third invocation no parameter
value is specified, so the default value of twenty stars is used.
The fourth and final call displays the parameter type checking, which is performed for
typed macro parameters. In this example a negative number of stars are requested, and
the interpreter indicates that the parameter is invalid.
$nmdat > mac fancytime {starline(#30); showtime; starline(#30)}
$nmdat > fancytime
******************************
The current time is: 2:17 PM
******************************
In this example a new macro named fancytime is defined. This new macro calls the two
previously defined macros in order to produce a fancy display of the time.
Macros can include calls to other macros. The contents of macro bodies are not inspected
when macros are defined. Therefore one macro can include a call to another macro before it
is defined.
%nmdebug > mac printsum (p1,p2=0) {wl "the sum is " p1+p2}
%nmdebug > printsum (1 2)
the sum is $3
%nmdebug > printsum 3 4
the sum is $7
%nmdebug > printsum 5
the sum is $5
Defines macro printsum that prints the sum of the two parameters p1 and p2. Note how
the parameters are referenced as simple local variables within the macro body. When a
macro is used as a command, parentheses around parameters are optional. Also note how
the default value (0) is used for the omitted optional parameter p2.
%cmdebug > mac is (p1="DEBUG",p2:str="GNARLY") {wl p1 "is very" p2.}
%cmdebug > is ("MPE" 'mysterious')
MPE is very mysterious.
%cmdebug > is ("mpe")
mpe is very GNARLY.
%cmdebug > is
DEBUG is very GNARLY.
These examples demonstrate simple typed parameters with default values. The default
values are used whenever optional parameters are omitted.
%nmdat > mac double (p1) { return p1*2 }
%nmdat > wl double(2)
$4
%nmdat > wl double(1+2)+1
$7
Defines macro double as a function with one parameter p1. The RETURN command is used