Declares a formal parameter within a command procedure. This
enables you to pass an actual parameter to the procedure when
entering an execute procedure (@) command.
Format
DECLARE p-name:p-kind [,p-name:p-kind[, . . . ]]
1 – Parameters
p-name
Specifies a formal parameter (a symbol) that is declared within
the command procedure.
Do not specify a null parameter (represented either by two
consecutive commas or by a comma at the end of the command).
p-kind
Specifies the parameter kind of a formal parameter. Valid
keywords are as follows:
ADDRESS Specifies that the actual parameter is interpreted
as an address expression. Same effect as
DEFINE/ADDRESS symbol-name = actual-parameter.
COMMAND Specifies that the actual parameter is
interpreted as a command. Same effect as
DEFINE/COMMAND symbol-name = actual-parameter.
VALUE Specifies that the actual parameter is interpreted as a
value expression in the current language. Same effect
as DEFINE/VALUE symbol-name = actual-parameter.
2 – Description
The DECLARE command is valid only within a command procedure.
The DECLARE command binds one or more actual parameters,
specified on the command line following the execute procedure
(@) command, to formal parameters (symbols) declared within a
command procedure.
Each p-name:p-kind pair specified by a DECLARE command binds one
formal parameter to one actual parameter. Formal parameters are
bound to actual parameters in the order in which the debugger
processes the parameter declarations. If you specify several
formal parameters on a single DECLARE command, the leftmost
formal parameter is bound to the first actual parameter, the
next formal parameter is bound to the second, and so on. If you
use a DECLARE command in a loop, the formal parameter is bound
to the first actual parameter on the first iteration of the loop;
the same formal parameter is bound to the second actual parameter
on the next iteration, and so on.
Each parameter declaration acts like a DEFINE command: it
associates a formal parameter with an address expression, a
command, or a value expression in the current language, according
to the parameter kind specified. The formal parameters themselves
are consistent with those accepted by the DEFINE command and can
in fact be deleted from the symbol table with the DELETE command.
The %PARCNT built-in symbol, which can be used only within a
command procedure, enables you to pass a variable number of
parameters to a command procedure. The value of %PARCNT is the
number of actual parameters passed to the command procedure.
Related commands:
@ (Execute Procedure)
DEFINE
DELETE
3 – Examples
1.! ***** Debugger Command Procedure EXAM_GO.COM *****
DECLARE L:ADDRESS, M:COMMAND
EXAMINE L; M
DBG> @EXAM_GO X "@DUMP"
In this example, the command procedure EXAM_GO.COM accepts two
parameters, an address expression (L) and a command string
(M). The address expression is then examined and the command
is executed.
At the debugger prompt, the @EXAM_GO X "@DUMP" command executes
EXAM_GO.COM, passing the address expression X and the command
string @DUMP.
2.! ***** Debugger Command Procedure VAR.DBG *****
SET OUTPUT VERIFY
FOR I = 1 TO %PARCNT DO (DECLARE X:VALUE; EVALUATE X)
DBG> @VAR.DBG 12,37,45
%DEBUG-I-VERIFYIC, entering command procedure VAR.DBG
FOR I = 1 TO %PARCNT DO (DECLARE X:VALUE; EVALUATE X)
12
37
45
%DEBUG-I-VERIFYIC, exiting command procedure VAR.DBG
DBG>
In this example, the command procedure VAR.DBG accepts a
variable number of parameters. That number is stored in the
built-in symbol %PARCNT.
At the debugger prompt, the @VAR.DBG command executes VAR.DBG,
passing the actual parameters 12, 37, and 45. Therefore,
%PARCNT has the value 3, and the FOR loop is repeated 3
times. The FOR loop causes the DECLARE command to bind each
of the three actual parameters (starting with 12) to a new
declaration of X. Each actual parameter is interpreted as a
value expression in the current language, and the EVALUATE X
command displays that value.