|
|
Defines a local variable within a macro body.
Syntax
LOC var_name [:var_type] [=] var_value
The LOC command can only be executed within a macro.
Local variables are known only to the macro in which they are defined.
The environment variable NONLOCALVARS may be changed so that local
variables are accessible to any macro called after a local variable has been
defined. (Refer to the ENV command).
Local variables are automatically deleted when the macro in which the variable
was defined finishes execution.
Parameters
- var_name
The name of the local variable being defined. Names must begin with an
alphabetic character and are restricted to thirty-two (32) characters,
that must be alphanumeric or an underscore (_), an apostrophe ('), or a
dollar sign ($). Longer names are truncated (with a warning). Names are
case insensitive.
- var_type
The type of the local variable. The following types are supported:
- STR
String
- BOOL
Unsigned 16 bit
- U16
Unsigned 16 bit
- S16
Signed 16 bit
- U32
Unsigned 32 bit
- S32
Signed 32 bit
- S64
Signed 64 bit
- SPTR
Short pointer
- LPTR
Long pointer
- PROG
Program logical address
- GRP
Group library logical address
- PUB
Account library logical address
- LGRP
Logon group library logical address
- LPUB
Logon account library logical address
- SYS
System library logical address
- USER
User library logical address
- TRANS
Translated CM code virtual address
If the type specification is omitted, the type is assigned automatically,
based on var_value.
The optional var_type allows the user to explicitly specify the
desired internal representation for var_value (that is, signed or
unsigned, 16-bit or 32-bit) for this particular assignment only. It does
not establish a fixed type for the lifetime of this variable. A
new value of a different type may be assigned to the same local variable
(name) by a subsequent LOC command.
- var_value
The new value for the variable, which can be an expression. An
optional equal sign "=" can be inserted before the variable value.
Examples
$nmdat > loc temp a.c000243c
Define local variable temp to be the address a.c000243c. By default,
this variable is of type LPTR (long pointer), based on the value.
$nmdebug > loc count=1c
Define local variable count to be the value 1c.
$nmdebug > loc s1:str="this is a string"
>Define local variable s1 to be of type STR (string) and
assign the value "this is a string".
nmdat > mac sum(p1 p2) {loc temp p1+p2; loclist; ret temp}
nmdat > wl sum (1 2)
var temp : U16 = $3
var loc p2 : U16 = $2
var loc p1 : U16 = $1
$3
This example shows how the LOCLIST command, when executed as part of
a macro body, displays all currently defined local variables. Note that the
macro parameters appear as local variables. Local variables are always listed
in the reverse order that they were created.
Limitations, Restrictions
none
|