Professional Documents
Culture Documents
Index 345
Acknowledgment
Micronetics Standard M (MSM) is a full implementation, with extensions, of the
ANSI Standard Specification (X11.1-1990) for the Massachusetts General Hospital
Utility Multi-Programming System. The M language was developed by the
Laboratory of Computer Science at Massachusetts General Hospital under grant
number HS00240 from the National Center for Health Services Research and
Development. M is a trademark of Massachusetts General Hospital.
Convention Description
RET The carriage return key (normally labeled RETURN, RET,
ENTER, etc.).
CTRL/X The Control key pressed at the same time as the X key,
where X is any valid key used in combination with the
Control key.
<ERROR> An MSM error message.
'val' In HELP messages, 'val' is used to indicate that the user
can enter the indicated value. The value is entered without
the quotes.
> The MSM Programmer prompt.
... The series of items repeats a user-specified number of
times.
. Shows a break in a list where consecutive lines have been
. omitted.
.
BOLD Items in a dialogue are shown in bold to indicate a user
response.
Overview
Micronetics Standard M (MSM) is a complete, versatile, and extremely powerful
implementation of the ANSI standard (X11.1 - 1990) M programming language. The
M language has been implemented in MSM through a language compiler and a
pseudo-code (p-code) interpreter. The language compiler converts M code into
pseudo-machine code that can be processed by the p-code interpreter. The rapid
interpretation of the p-code during program execution allows applications to run in a
stand-alone environment or under a host operating system with exceptionally fast
response time.
Even though MSM has been implemented as a compiler, it still provides all of the
flexibility of an interpreter. M code can be entered directly from the keyboard into
the compiler to provide instantaneous results without a separate compilation step.
The file system in MSM has been implemented using a compressed-key, B-tree
structure to ensure optimum performance. The system supports a disk buffer cache,
delayed write operations on modified buffers, and other performance features aimed
at maximizing throughput.
Delimiters
Delimiter characters are recognized by the compiler to separate various pieces of the
language so that an unambiguous translation can be made. The following table lists
the delimiter characters that are recognized by the MSM system.
'HOLPLWHU &KDUDFWHUV
Character Description
, A comma is used to separate arguments and subscripts.
= An equal sign performs value assignment and tests for equality in an
expression.
: A colon is used to separate a post-conditional expression from a command
and to separate sub-arguments within a command.
() Parentheses are used for grouping subscripts, function arguments, elements
within complex expressions, etc.
@ An at-sign indicates indirection in an expression (evaluate the expression and
use the result).
" Double quotes are used to form a string literal by bounding a string of
information.
; A semicolon indicates the beginning of a comment field within a command
line or at the beginning of a command line.
^ A circumflex character separates a line label from a routine name in a DO or
GOTO command, denote globals, etc.
E An uppercase E indicates where the exponent portion of a numeric literal
begins in pattern matching operands (for example, 1.23E7).
. A period indicates where the fractional part of a numeric literal begins (for
example, 123.45).
SP A space character separates arguments from commands and commands from
commands within a line of a routine.
Prefixes
Prefix characters are recognized by the compiler to distinguish global variable names,
function names, special variable names, and special routine names from local
variable names. The following table lists the prefix characters that are recognized by
the compiler in the MSM system.
Line Terminators
Line terminators are recognized by the compiler to signal the end of data input to the
compiler or a program. The following table lists the default line terminators
recognized by the system.
/LQH 7HUPLQDWRUV
Character Description
RET Signals the end of input to the compiler or an executing routine.
ESC Signals the end of input unless escape processing is enabled.
Format Characters
Format characters can be used in READ or WRITE commands to send carriage
control commands to a device. The following table lists the format characters
recognized by MSM.
)RUPDW &KDUDFWHUV
Character Description
# A pound sign instructs the system to send a carriage return and a form-feed
sequence to the device. The $X and $Y special variables are reset to 0.
! An exclamation point instructs the system to send a carriage return and a
line-feed sequence to the device. The $X special variable is reset to 0, and
the $Y special variable is incremented by 1.
? A question mark followed by an integer value indicates the column where
the next output is to take place. The $X special variable is adjusted to
reflect the new output position, and the $Y special variable is not changed.
/ A slash indicates the start of a mnemonic namespace request.
&RQWURO &KDUDFWHUV
Character Description
BACKSPACE Backspaces the cursor one position. This is equivalent to the CTRL/H
sequence.
DEL Deletes the last character entered from the terminal and backspaces the
cursor one position.
ESC Terminates the current input operation if escape processing is disabled.
Otherwise, one more character is read from the terminal, and the input
operation is terminated.
RET Terminates the current input operation. This is equivalent to a CTRL/M
sequence.
TAB Moves the cursor to the next tab position (tab stops are every eight
positions). It is also used as the separator between the line label and the
line body when entering M code into a program. This key is equivalent
to entering the CTRL/I sequence.
CTRL/I Moves the cursor to the next tab position (tab stops are every eight
positions). It is also used as the separator between the line label and the
line body when entering M code into a program. This is equivalent to
entering TAB.
CTRL/L Performs the same function as entering a form feed character. This
character is echoed back to the terminal. The action taken depends on
the terminal connected to the system.
CTRL/M Terminates the current input operation. This is equivalent to RETURN.
CTRL/O Suspends all output to a terminal. Any information sent to the terminal
by the system is discarded. Output to the terminal is resumed when the
system receives another CTRL/O character.
CTRL/Q Resumes output to the terminal that was suspended using the CTRL/S
function.
CTRL/R Reprints the current input line and leaves the cursor positioned at the
end of the line.
CTRL/S Suspends all output to the terminal. Information is not lost, and output is
resumed when a CTRL/Q is received.
CTRL/U Deletes the current input line (erases all characters typed so far) and
re-prompts for input.
CTRL/X Deletes the current input line, displays (DELETED) on the same line,
and re-prompts for input.
Refer to "Using Peripheral Devices," in the MSM User's Guide for information on
preventing or altering interpretation of these control characters by MSM.
Commands
A command is the method by which the compiler is directed to perform a specific
action. Each command in M performs a specific task that is further defined by the
arguments passed to the compiler with the command. In addition to the
ANSI-standard M commands, MSM includes commands that provide increased
capability and functionality in the language. These commands begin with the letter Z.
Functions
Built-in functions in MSM provide the programmer with a powerful set of
capabilities to perform common operations. While most of these functions can be
accomplished using a series of M commands, these built-in functions allow the
programmer to specify a complete operation with a single instruction to the compiler.
MSM function names always begin with a dollar sign ($). In addition to the
ANSI-standard M functions, MSM includes that provide increased capability and
flexibility. These commands begin with a dollar sign followed by the letter Z.
Special Variables
Special variables are designed to provide feedback information for executing
programs as they interact with the operating system and the user. These variables are
maintained by the MSM system and can be examined by a program as it executes.
Based on the content of these variables, decisions can be made that alter the flow of
execution. MSM special variable names always begin with a dollar sign ($). In
addition to the ANSI-standard M special variables, MSM includes special variables
that provide supplementary feedback. These special variables begin with a dollar sign
followed by the letter Z.
The vast majority of commands in MSM allow the user to specify more than one
argument. When multiple arguments are specified on a command, the arguments are
separated from each other by commas. This collection of arguments is referred to as
an argument list. The following example illustrates the use of an argument list.
WRITE SP "HELLO","!"
The same result can be achieved without an argument list. Instead, the command can
be specified repeatedly with each of the arguments in the argument list. The
following example is equivalent to the previous example.
WRITE SP "HELLO" SP WRITE SP "!"
Routine Structure
When one or more command lines are grouped together to form a routine, the
command lines are considered to be routine lines. A routine line is the same as a
command line except that it is preceded by a TAB and optionally can include a line
label that uniquely identifies the routine line. A line label can be either an integer
value (for example, 1, 123, 765,) or a name. If it is a name, it must begin with either a
percent sign (%) or an alpha character. Characters after the first character can be any
alpha-numeric value. If the label is more than eight characters, MSM ignores all
characters after the eighth character. The following are examples of valid labels.
ABC
400
%12
%A99
In the previous example, the label indicated the third routine line after the routine line
labeled LINE1. Although this syntax is grammatically correct, it generally is not used
because it can cause unexpected results if routine lines are added or deleted from the
routine.
Floating point numbers are similar to integers, except that they contain a fractional
part that follows the integer value. The fractional part is separated from the integer
part by a decimal point. A floating point number may contain one and only one
decimal point, and it need not contain an integer portion. If there is no integer
portion, the number begins with a decimal point and is followed by at least one digit.
Literals
In MSM, a literal is a string that is enclosed within quotation marks (" "). If the quote
character is to appear in the literal, it is indicated by two consecutive quotes. The
value of a literal can be acted upon by a command, but it cannot be changed by a
command. The following are examples of valid literals.
"THIS IS AN EXAMPLE OF A LITERAL"
"123.456"
"99+44"
"!#$%|& SPECIAL CHARACTERS"
A literal can contain any valid ASCII character. When a literal is entered from a
terminal, certain characters may be excluded from input because they have meaning
to MSM. Refer to "Control Characters" in this chapter for additional information.
Constants
A constant is a numeric value that is fully specified in an expression and whose value
cannot be changed. The numeric value can be an integer or a floating point number.
The following are examples of constants.
1234
-123.9876E3
986.65
0
Object References
Objects are an "encapsulation of functionality and data values." Associated with each
object is a set of properties and methods that represent values and functionality,
respectively. The value associated with a property or method can be numeric or string
or a reference to other objects (if the object is a container for other objects). An
object reference has no graphic representation. It represents a "link" to an interface to
packaged functionality and values.
Local Variables
Local variables (locals) are temporary and exist only for the duration of a terminal
session. Locals are created by referencing them in a SET or READ command or
within parameter passing. They can be removed by referencing them in a KILL or
NEW command or a QUIT command when exiting a routine invoked with parameter
passing. When a local is created, it is assigned to the user who created it and is
known only by that user. Two users may have local variables that have the same
name but have different values.
A local variable name must begin with a percent sign (%) or an alpha character. It
can be followed by any combination of alpha-numeric characters. If the name
contains more than eight characters, MSM ignores all characters after the eighth
character. The following are examples of valid local variable names.
ABC
%123
X21
The data value assigned to a local variable can be a maximum of 4092 characters in
length or can be an object reference, and the local variable optionally can include one
or more subscripts. Refer to "Arrays and Subscripts" in this chapter for additional
information.
Global Variables
Global variables (globals) are permanent and continue to exist after a terminal
session ends. Globals are created by referencing them in a SET or READ command,
and they are removed by referencing them in a KILL command. When a global is
created, it is assigned a permanent location in the MSM database and can be known
to users other than the user who created it. Thus, two users can both reference one
global variable and obtain the same value.
A global variable name must begin with a circumflex (^) followed by a percent sign
(%) or an alpha character, followed, in turn, by any combination of alphanumeric
characters. If the name contains more than eight characters, MSM ignores all
characters after the eighth character. A global variable name can be distinguished
from a local variable name by the circumflex (^) that precedes it. The following are
examples of valid global variable names.
^CUSTFILE
^%999
^CTRL12
In the first example, customers are ordered into an array in which the first customer is
number 1, the second is number 2, and so on. Arrays can be more complex,
containing additional levels of information.
The following example illustrates a more complex array in which invoice and address
information is added to the array shown in the first example.
^CUSTOMER(1,1)
^CUSTOMER(1,3,2)
^CUSTOMER(2,99)
^CUSTOMER(2,"INVOICE",18761)
.
.
.
^CUSTOMER(998,"ADDRESS")
^CUSTOMER(999,".01")
^CUSTOMER(999,".01",".997","TEST RESULT")
Execution of a naked reference when the naked indicator is null results in an error
condition (<NAKED> error code). When the naked indicator is defined, the
subscripts specified in the naked reference are appended to the right of the right-most
subscript of the naked indicator to form the full reference.
Because the right side of a SET statement is evaluated first, care should be exercised
to prevent unwanted or unexpected results when using naked references. For
example:
I '$D(^ABC(1)) S ^(1)=^XYZ(1,2) ;does not set ^ABC(1)
I '$D(^ABC(1)) S ^XYZ(1,1)=^XYZ(1,2) ;is equivalent to the above
Collating Sequence
Subscripted global variables can include numeric valued subscripts, string-valued
subscripts, or a combination of both. For this reason, MSM allows the user to specify
the order in which the subscripts are to be collated. Either numeric sequence or string
sequence can be specified.
For globals in which a collating sequence string type was specified, all subscripts
(numeric and non-numeric) are treated as character strings and stored in ASCII
collating sequence.
In globals in which the collating sequence is numeric, the system stores canonic
numbers (numeric values with no leading zeroes or trailing zeroes after the decimal
point) first, followed by the non-numeric values in ASCII collating sequence.
In the following example, global variable X has the same subscripts as in the prior
example, and numeric collating sequence is assigned. The subscript values are stored
in the following order.
^X(-10)
^X(-2)
^X(-1)
^X(0)
^X(1)
^X(1.1)
^X(2)
^X(3)
^X(10)
^X(20)
^X(30)
^X("ABC")
In this notation, UCI is an expression that evaluates to the three-character UCI name
(for example, MGR). The VolName field is an expression that evaluates to the
three-character volume group name where the global resides. If VolName is omitted,
the system uses the current volume group. The variable name is any global variable
name (subscripted or unsubscripted).
Special Variables
As explained in "Language Components" in this chapter, special variables are
reserved variable names whose value is determined by the MSM system. Generally,
special variable names can be used anywhere that constants and variable names can
be specified. The exception is that many of the special variable names cannot be used
in assignment commands or parameter passing by reference because their value
cannot be changed.
MSM supports external (non-M) objects on platforms that support OLE/2 objects.
These external objects often have member names that do not strictly conform to M
naming rules (such as the member name calculate_interest, in which the underscore
character would mean concatenation in M). These member names require the use of
quotes around the member name, followed by the optional parameters. The following
example illustrates this requirement.
myobj(1,2).”directory_lookup”(path).fileame.”size of file”
In the example, the parameter is specified outside the quotes. Any character can
appear inside the quotes, including a quote (which must be double-quoted, i.e., two
consecutive quotes used to represent a single embedded quote).
While the current maximum member length is 31 characters (MSM ignores any
characters after the thirty-first), it is good practice to limit names to 31 characters to
allow future expansion to longer names as object technology evolves.
Default Values
OLE/2 objects may have a default property that retrieves the value associated with an
object reference when a member name is not explicitly specified. This feature of
OLE/2 objects is supported by MSM.
For example, cell(3,9) is a local variable whose value is an object reference to cell
(3,9) of a Microsoft Excel spreadsheet. The command WRITE cell(3,9) invokes the
default member function associated with the Excel object (the contents of the cell in
the spreadsheet), which then is displayed on the current output device. Explicit
members also can be specified (such as cell(3,9).font or cell(3,9).width, etc.). An
object's default property can be referred to explicitly by suffixing the expression with
a period and omitting the member name (for example, cell(3,9)).
There are two major benefits in allowing default values: variables that contain object
references can participate transparently in any M expressions, and there is immediate
compatibility with OLE/2 objects both as M and non-M objects.
When the last member of an object reference returns an object reference, the default
property of that last object reference is invoked whenever the entire object expression
appears as part of an M expression, except as noted in the sections below. This means
that SET A=B assigns to local variable A the value of the default property of B
(assuming that B contains an object reference). Even if local variable A originally
contained an object reference, it is replaced by the value of B (the value returned by
the default property). The command SET cell(3,9)=3 attempts to assign a value of 3
to the default property of the cell(3,9) object. Similarly, IF A=B compares the values
returned by the default properties of A and B.
Overview
The building blocks that are used to form expressions in M include: functions,
literals, variables, unary operators, and binary operators.
An expression is a substring of a command which, when executed, produces a value.
The execution (evaluation) of expressions is the principal means by which values are
obtained for subscripts, for arguments of functions, and for assignment of variables.
The simplest element of an expression is an expression atom. An expression atom can
be an intrinsic or extrinsic function, a literal, a variable, or another expression atom
preceded by a unary operator.
In its simplest form, an expression can be a single expression atom. For example, the
following are simple expressions.
123.45 A numeric literal
CUST A local variable name
$DATA(X) A function
-X A local variable name preceded by a minus sign
Expressions also can be complex, limited only by practical issues such as command
line length and readability. Generally, complex expressions are formed by combining
expression atoms with binary operators.
Building Expressions
Two fundamental rules apply to the process of building expressions. First, every
expression must contain at least one expression atom. By definition, an expression
atom is an intrinsic or extrinsic function, a literal, a variable, a constant, or another
expression atom preceded by a unary operator.
Second, an expression is defined to be an expression atom, two expression atoms
separated by a binary operator, or an expression enclosed in parentheses. By
definition, an expression atom is an expression. The following examples illustrate
expressions.
Evaluating Expressions
Expressions generally are evaluated in a strict left-to-right order. First, within the
expression atom, the system evaluates all indirection operators in a left-to-right
sequence. Each occurrence of indirection is replaced with the value of the
indirection.
Next, all unary operators are evaluated and the appropriate action is applied to the
operand to the right of the unary operator. If multiple unary operators appear in a
sequence, each operator is applied one-by-one in a left-to-right order.
Finally, all binary operators are evaluated in a left-to-right order. Unlike other
languages, all binary operators have equal precedence (there is no specified
evaluation sequence for binary operators). The strictly left-to-right order in which
binary operators are evaluated can be changed by enclosing expressions in
parentheses.
When an expression contains one or more subexpressions (an expression enclosed in
parentheses), then the subexpressions are evaluated first in a left-to-right order. This
is done before the binary operator is applied. The same rule applies if the
subexpression contains a subexpression.
When an expression is evaluated, its result can be considered a character string,
which is the only data type defined in MSM. However, based on the usage of the
result, an implicit data type may be required. In MSM, certain commands and
functions expect implicit data types.
The following types of expression are used in MSM.
• Numeric expressions
• String expressions
• Truth-valued expressions
• Post-conditional expressions
The following sections describe these expression types and the rules that pertain to
them.
String Expressions
A string expression in MSM is one in which the operands contain any valid ASCII
character string. No interpretation is given to the operands. The binary
CONCATENATE operator or any of the string relational operators (CONTAINS or
FOLLOWS) can be used in string expressions.
The operands are considered to be variable length strings with a given value. For the
CONCATENATE operator, the value of the expression is the value of the second
operand concatenated to the value of the first operand. For relational values, the
result is a Boolean true (1) or a Boolean false (0) value.
Truth-Valued Expressions
A truth-valued expression is one in which the operands are interpreted as Boolean
truth values. The expression may contain either binary relational operators or binary
logical operators.
When the expression is evaluated, if the relationship between the operands is true, the
expression is assigned a Boolean true value (1). Otherwise, a Boolean false value (0)
is assigned to the expression.
Post-Conditional Expressions
A post-conditional expression is used to conditionally execute a command or
argument of a command. When it is used to control execution of a command, it is
referred to as a command post-conditional. In the case of conditional execution of an
argument, it is referred to as an argument post-conditional.
A post-conditional expression consists of a colon (:) followed by a truth-valued
expression. In a command post-conditional, the expression is appended to the
command word. In an argument post-conditional, the expression is appended to the
argument.
Overview
The M language provides operators that are used to specify an action that is to be
performed. The following table summarizes MSM operators and their characteristics.
060 2SHUDWRUV
Operator Name Type Characteristics
+ ADDITION Binary Arithmetic
& AND Binary Logical
_ CONCATENATE Binary String
/ DIVIDE Binary Arithmetic
= EQUAL TO Binary Relational
** EXPONENTIATION Binary Arithmetic
> GREATER THAN Binary Relational
# HEXADECIMAL Unary Arithmetic
@ INDIRECTION Unary Unary
\ INTEGER DIVISION Binary Arithmetic
< LESS THAN Binary Relational
- MINUS Unary Arithmetic
# MODULO DIVISION Binary Arithmetic
* MULTIPLICATION Binary Arithmetic
' NOT Unary Logical
! OR Binary Logical
? PATTERN MATCH Binary Binary
+ PLUS Unary Arithmetic
[ STRING CONTAINS Binary Relational
] STRING FOLLOWS Binary Relational
]] STRING SORTS AFTER Binary Relational
- SUBTRACTION Binary Arithmetic
For additional information on writing programs using operators, refer to the MSM
User's Guide.
Syntax
operand1+operand2
Definition
The ADDITION operator evaluates each operand as a numeric value and then
computes the algebraic sum of the two values.
Considerations
The result of the ADDITION operation is accurate to 16 or 17 digits of precision,
depending on the values of the operands.
Associated Topics
Numeric Expressions
Examples
WRITE 2+2
W 986.513+2081.6
W "123XYZ"+"456ABC"
W "123XYZ"+"ABC"
Writes the value 123 because the string "ABC" evaluates to zero as a number.
Syntax
operand1&operand2
Definition
The AND operator evaluates each operand as a truth value and then tests both
operands to see if they are true. An operand is true if its numeric value is non-zero.
Otherwise, its value is false. If both operands are true, a value of 1 (true) is returned;
otherwise, a value of 0 (false) is returned.
Considerations
The Boolean NAND operator (NOT AND) can be obtained by preceding the AND
operator with the NOT operator ( ' ) to form the NAND operator ('&).
Associated Topics
Truth-Valued Expressions
Examples
WRITE 5&4
W 1&0
Writes the value 0 because the second operand is not true (0).
SET X="123XYZ"&"456ABC"
Sets X to the value 1 because operand1 evaluates to 123 and operand2 evaluates to 456.
S Y="123XYZ"&"ABC"
Syntax
operand1_operand2
Definition
The CONCATENATE operator treats both operands as string values and forms a
new string by appending operand2 to the end of operand1. The length of the new
string is the sum of the lengths of operand1 and operand2. MSM generates an error if
the result produces a string longer than the maximum string size allowed for a local
or a global variable, and the result is assigned to a local or global variable.
Considerations
Although the string generated by the CONCATENATE operation can be a maximum
of 4092 characters in length, strings of this size can be assigned only to local
variables. Any attempt to assign a string of this length to a global variable results in
an error. For globals, system administrator can set the maximum size to 255 or 511.
Associated Topics
String Expressions
Examples
WRITE "BASKET"_"BALL"
W "1,"_"234"_",567."_89
Writes the string "HELLO JIM, WELCOME TO MSM." to the current device.
Syntax
operand1/operand2
Definition
The DIVISION operator evaluates each operand as a numeric value and then
computes the quotient that is the result of dividing operand1 by operand2.
Considerations
The result of the DIVISION operation is accurate to 16 or 17 digits of precision,
depending on the values of the operands. Any attempt to perform division by zero
results in an error.
Associated Topics
Numeric Expressions
Examples
WRITE 4/2
W "246XYZ"/"123ABC"
Writes the value 2 because the first string evaluates to 246 and the second string evaluates to
123.
Syntax
operand1=operand2
Definition
The EQUAL TO operator treats both operands as string values and compares them to
determine if they are identical (operand1 exactly matches operand2). If the strings are
identical, the operator returns a value of 1 (true); otherwise, it returns a value of 0
(false). This operator does not test for numeric equality; it is strictly a string-
comparison operation. However, if both operands are written as numeric literals, the
compiler evaluates them as numeric values. At execution time, string values of the
numeric literals are compared, and leading and trailing zeros after the decimal point
are ignored.
Considerations
The Boolean NOT EQUAL TO operator can be obtained by preceding the EQUAL
TO operator with the NOT ( ' ) operator to form the NOT EQUAL TO operator ( '=).
Associated Topics
String Expressions Truth-Valued Expressions
Examples
WRITE "ABC"="ABC "
W "123"="00123"
W 123=00123
Writes the value 1 because the values are equivalent numeric literals.
W +"123"=+"00123"
Writes the value 1 because numeric conversion is forced by the PLUS operator.
Syntax
operand1**operand2
Definition
The EXPONENTIATION operator evaluates each operand as a numeric value and
then computes a new value that is the result of raising operand1 to the power
specified by operand2.
Considerations
The result of the EXPONENTIATION operation is accurate to 16 or 17 digits of
precision, depending on the values of the operands. If a negative power is specified
(operand2 is less than zero) and it is not an integer, and operand1 is less than zero, an
error occurs. If a positive non-integer power is specified and operand1 is negative, an
error occurs. If zero is raised to a negative power (operand1 is zero and operand2 is
negative), an error occurs.
Associated Topics
Numeric Expressions
Examples
WRITE 8**2
W "16ABC"**"4XYZ"
Syntax
operand1>operand2
Definition
The GREATER THAN operator evaluates each operand as a numeric value and then
performs a numeric comparison of the two values. If the numeric value of operand1 is
strictly greater than the numeric value of operand2, the operator returns a value of 1 (true);
otherwise, it returns a value of 0 (false).
Considerations
The Boolean NOT GREATER THAN operator can be obtained by preceding the
GREATER THAN operator with the NOT ( ' ) operator to form the NOT
GREATER THAN operator ('>). The NOT GREATER THAN operator is equivalent
to the LESS THAN OR EQUAL TO Boolean operation.
Associated Topics
Numeric Expressions Truth-Valued Expressions
Examples
WRITE "123">"456"
W "123">"001"
Writes the number 1 (true) because operand1 evaluated as a number is greater than operand2
evaluated as a number.
W "DEF">"ABC"
W "123XYZ">"456ABC"
Writes the number 0 (false) because the numeric value of operand1 (123) is not greater than
the numeric value of operand2 (456).
Syntax
#operand
Definition
The HEXADECIMAL operator computes the decimal value of the operand, which
must be a valid hexadecimal number. A valid hexadecimal number includes the digits
0 through 9 and the letters A through F. The letters can be specified in uppercase,
lowercase, or a mixture of uppercase and lowercase characters.
Considerations
The HEXADECIMAL operator can be used in WRITE commands; however, care
must be taken so that the operator is not mistaken for the eject page format character
(#).
Associated Topics
Constant Values
Examples
WRITE +#3FD
Writes 1021 to the current device. The PLUS operator forces numeric conversion, thus
allowing the # operator to be recognized.
SET X=#1efd
S Y=#3BFC\#FF W Y
Writes 60 to the current device. First, the two hexadecimal operands are evaluated, and then
the integer division is performed.
Syntax
@Expression Atom
@Expression Atom@(Subscript{,...Subscript})
Definition
The INDIRECTION operator is used to dynamically alter the M code within a
command. When indirection is encountered in a command, the indirection expression
is evaluated and the derived value is substituted for the indirection before the
command is executed. There are four types of indirection: name indirection,
argument indirection, pattern indirection, and subscript indirection. The indirection
types are described in the following paragraphs.
Name Indirection
When an indirection expression atom is evaluated, it must yield a valid MSM name.
The name derived from the expression atom may be a routine name, variable name,
or line label. Names can begin with a percent sign or an alpha character and can be
followed by any number of alphanumeric characters. For a variable name, subscripts
also can be specified as part of the indirection. This type of indirection can be used
with commands such as DO, GOTO, and SET.
Argument Indirection
When an indirection expression is evaluated, it must yield one or more complete
command arguments. The form of the derived argument or arguments is specific to
the command being used with indirection. The command detects any errors in the
argument structure. This type of indirection can be used on all commands unless
explicit restrictions are noted on the command.
Pattern Indirection
When the indirection expression is evaluated, it must yield a valid pattern for the
PATTERN MATCH operator. Refer to "Pattern Match" in this chapter for
information on valid patterns. This type of indirection can be used only with the
PATTERN MATCH operator.
Subscript Indirection
When an indirection expression is evaluated, it must yield a valid subscripted local or
global variable name). This type of indirection is in the following form:
@Expression Atom@(Subscript{,...Subscript})
An expression atom must yield a valid variable name (with or without subscripts).
(Subscript{,...Subscript}) is a list of subscripts enclosed in parentheses and separated
by commas. The two pieces of the indirection are combined to form a complete
subscripted variable name by appending the explicit subscripts to the variable name
and subscripts obtained from the expression atom.
Associated Topics
Expression Atom PATTERN MATCH Operator
This form of name indirection writes the string "YOU ARE NOW LOGGED ON AS "
followed by the value of the local variable USRNAME to the current device.
S X="3N1""-""2N1""-""4N" W "123-45-6789"?@X
This form of pattern indirection writes 1 to the current device because the string conforms to
the indicated pattern.
S X="^CUS(ID)",ID="JONES",Y=@X@(1,100,0)
This form of subscript indirection sets the local variable Y to the value of the
^CUS("JONES",1,100,0) global.
S X="^CUS(ID)",ID="JONES",Y=@X@(1,100,0)
S X="A",y="1^2^3",Z="$PIECE(Y,""^"",2)"
A",y="1^2^3",Z="$PIECE( commands:
Y,""^"",2)"
S @(X_"="_Z)
S @(X_" A=2.="_Z)
S ARG=X_"="_Z S @ARG@ARG
S @X=@Z
This command is a common misuse of indirection. It incurs an error because Z does not
evaluate to a name. This is an attempt to use name indirection with an expression.
Syntax
operand1\operand2
Definition
The INTEGER DIVISION operator evaluates each operand as a numeric value. It
then computes a result that is the integer portion of the quotient that results from
dividing operand1 by operand2. The fractional part of the result is not returned.
Considerations
The result of the INTEGER DIVISION operation is accurate to 16 or 17 digits of
precision, depending on the values of the operands. Any attempt to perform integer
division by zero results in an error.
Associated Topics
Numeric Expressions
Examples
WRITE 4\2
Writes the value 39 to the current device. The fractional part of the result
(.317197452229299) is discarded.
W "456XYZ"\"123ABC"
Writes the value 3 because the first string evaluates to 456 and the second string evaluates to
123. The remainder value is discarded.
Syntax
operand1<operand2
Definition
The LESS THAN operator evaluates each operand as a numeric value and then
performs a numeric comparison of the two values. If the numeric value of operand1 is
strictly less than the numeric value of operand2, the operator returns a value of 1
(true); otherwise, it returns a value of 0 (false).
Considerations
The Boolean NOT LESS THAN operator can be obtained by preceding the LESS
THAN operator with the NOT ( ' ) operator to form the NOT LESS THAN operator (
'<). The NOT LESS THAN operator is equivalent to the GREATER THAN OR
EQUAL TO Boolean operation.
Associated Topics
Numeric Expressions Truth-Valued Expressions
Examples
WRITE "123"<"456"
W "123"<"001"
Writes the number 0 ( false) because operand1 evaluated as a number is greater than operand2
evaluated as a number.
W "DEF"<"ABC"
W "123XYZ"<"456ABC"
Writes the value 1 because the numeric value of operand1 (123) is less than the numeric value
of operand2 (456).
Syntax
-operand
Definition
The MINUS operator evaluates the operand as a numeric value and then reverses the
sign of the numeric value.
Considerations
The MINUS operator has precedence over the arithmetic operators. This means that
when an expression is evaluated, the MINUS operator is evaluated before the
arithmetic operations.
Associated Topics
Expression Evaluation Numeric Expressions
Examples
WRITE -3
W 123--456
Writes the value 579 to the current device because the MINUS operator inverts the subtraction
to addition.
W -"123XYZ"
Writes the value -123 to the current device because the string evaluates to the positive number
123, and the inverse is -123.
W -"ABC"
Writes the value 0 to the current device because the string "ABC" has a numeric value of 0.
Syntax
operand1#operand2
Definition
The MODULO DIVISION operator first evaluates each operand as a numeric value.
It then computes a result that is the remainder portion of the quotient derived by
dividing operand1 by operand2 according to the following formula.
operand1 - (operand2 * FLOOR(operand1/operand2))
The function FLOOR(x) is defined as the largest integer that does not exceed the
value of x. The following example illustrates the FLOOR function.
FLOOR(5)=5 FLOOR(4.5)=4 FLOOR(-1)=-1 FLOOR(-1.5)=-2
In the MODULO DIVISION operation, the integer portion of the quotient is not
returned.
When both operands are positive, the MODULO DIVISION operator yields the
familiar remainder function. For negative values, the results are not immediately
obvious.
The following table illustrates the results. In the table, R is the remainder of the
absolute value of operand1 divided by the absolute value of operand2. The table
shows the results if R is a non-zero value.
operand1<0 operand1≥0
operand2<0 -R operand2+R
operand2≥0 operand2-R R
Considerations
The result of the MODULO DIVISION operation is accurate to 16 or 17 digits of
precision, depending on the values of the operands. Any attempt to perform modulo
division by zero results in an error.
Associated Topics
Numeric Expressions
Writes the value .996 (the remainder) to the current device. The integer portion of 39 is
discarded.
W "456XYZ"#"123ABC"
Writes the value 87 because the first string evaluates to 456 and the second string evaluates to
123. The integer portion of 3 is discarded.
W 5#(-3)
W -5#3
W -5#(-3)
W 4#1.5
Syntax
operand1*operand2
Definition
The MULTIPLICATION operator evaluates each operand as a numeric value and
then computes the product that is the result of multiplying operand1 by operand2.
Considerations
The result of the MULTIPLICATION operation is accurate to 16 or 17 digits of
precision, depending on the values of the operands.
Associated Topics
Numeric Expressions
Examples
WRITE 4*2
W "246XYZ"*"123ABC"
Writes the value 30258 because the first string evaluates to 246 and the second string
evaluates to 123.
Syntax
'operand
Definition
The NOT operator takes as its argument either an M relational or logical operator (!,
=, >, etc.) or a Boolean truth value (0 or 1). It inverts the value of the operator or the
Boolean truth value. If the truth value is true (1), it becomes false (0), and if it is false
(0), it becomes true (1). With operators, it reverses the value of the operation result.
Considerations
The value of a relational operation can be reversed using either of the following
methods:
operand1 'Relation operand2 '(operand1 Relation operand2)
Associated Topics
Truth-Valued Expressions
Examples
WRITE '1
W 123'<456
Writes the value 0 to the current device because 123 is not less than 456.
W '(123<456)
Writes the value 0 to the current device because 123 is less than 456 and the inverse of that is
false.
Syntax
operand1!operand2
Definition
The OR operator evaluates each operand as a truth value and then tests both operands
to see if either or both are true. An operand is true if its numeric value is non-zero.
Otherwise, its value is false. If either one or both are true, a value of 1 (true) is
returned; otherwise, a value of 0 (false) is returned.
Considerations
The Boolean NOR operator ( NOT OR) can be obtained by preceding the OR
operator with the NOT ( ' ) operator to form the NOR operator ( '!).
Associated Topics
Truth-Valued Expressions
Examples
WRITE 5!4
W 1!0
SET X="123XYZ"!"456ABC"
Sets X to the value 1 because operand1 evaluates to 123 and operand2 evaluates to 456.
SET Y="XYZ"!"ABC"
Syntax
operand?pattern
Definition
The PATTERN MATCH operator tests to see if the string specified by the operand is
in the form indicated by the pattern that appears after the operator. If it is in the
correct form, the PATTERN MATCH operator returns a value of 1 (true). Otherwise,
it returns a value of 0 (false).
Combinations of the pattern characters listed in the following table can be used to
specify the pattern. Refer to Appendix A, "ASCII Collating Sequence," in this
document for additional information on the ASCII character set.
&RGH 'HVFULSWLRQ
Code Description
A or a The 52 alphabetic characters (all uppercase characters and all lowercase
characters)
C or c The 33 ASCII control characters (decimal values 0 through 31 and decimal
value 127)
E or e All 128 ASCII characters plus the 128 extended ASCII characters (matches
everything)
L or l The 26 lowercase alphabetic characters
N or n The 10 numeric digits 0 through 9
P or p The 32 punctuation characters plus the SP character
U or u The 26 uppercase alphabetic characters
( Indicates the start of a logical OR pattern group
) Indicates the end of a logical OR pattern group
, Used to separate individual patterns in a logical OR pattern group
Considerations
Pattern match codes can be specified in uppercase, lowercase, or a combination of
uppercase and lowercase characters. If the PATTERN MATCH operator is preceded
by the NOT ( ' ) operator, the logic of the operation is inverted.
Pattern match codes A, C, N, L, P, and U are defined only for the standard 128
ASCII characters. The pattern match code E now is extended to match all 256
characters (128 ASCII and 128 Extended ASCII).
Associated Topics
ASCII Character Set INDIRECTION Operator Truth-Valued Expressions
Examples
SET X="3N1""-""2N1""-""4N" WRITE "123-45-6789"?@X
This pattern match writes 1 to the current device because the specified string conforms to the
indicated pattern.
WRITE "JONES,JOHN"?1A.A1","1A.A
This pattern tests to see if the string is one or more alphabetic characters followed by one and
only one comma followed by one or more alphabetic characters. In this case, the pattern match
writes a 1 to the current device.
IF X?2N1(3P2A,2P3A).E
This example shows how a logical OR condition can be specified within a PATTERN
MATCH operation. The pattern shown in this example is equivalent to the following:
I (X?2N3P2A.E)!(X?2N2P3A.E)
Syntax
+operand
Definition
The PLUS operator evaluates the operand as a numeric value and preserves the sign
of the numeric value. The numeric value of an operand is the leading portion of the
operand that includes the MINUS operator, the PLUS operator, the letter E, a
decimal point, and the digits 0 through 9.
Considerations
The PLUS operator only forces conversion of a string to a numeric value. It does not
alter the sign of the converted string.
Associated Topics
Numeric Expressions
Examples
WRITE +"123XYZ"
W 123=+"123ABC"
Writes the value 1 to the current device because the PLUS operator forces numeric conversion
and the values are then equal.
W +"-123XYZ"
Writes the value -123 to the current device because the string evaluates to the negative number
-123.
W +"ABC"
Writes the value 0 to the current device because the string "ABC" has a numeric value of 0.
Syntax
operand1[operand2
Definition
The STRING CONTAINS operator tests if the string specified by operand2 is
contained within the string specified by operand1. If it is, the operator returns a value
of 1 ( true); otherwise, it returns a value of 0 (false). The string specified by operand 2
must match exactly a substring contained in operand1 (the substring must be the same
length and the characters must be in the same order). By definition, if operand2 is
null (a string of zero length), the operator always returns a value of 1.
Considerations
The STRING DOES NOT CONTAIN operator can be obtained by preceding the
STRING CONTAINS operator with the NOT ( ' ) operator. This forms the DOES
NOT CONTAIN relational operator ( '[).
Associated Topics
String Expressions Truth-Valued Expressions
Examples
WRITE "ABCDEFGHI"["DEF"
W "123456"["246"
Writes 0 to the current device because "246" is not contained as a substring in "123456"
W "TEST STRING"[""
Writes 1 to the current device because the null string is contained in all strings.
Writes 1 to the current device because the zip code specified by operand2 is contained in
operand1.
Syntax
operand1]operand2
Definition
The STRING FOLLOWS operator tests to see if the string specified by operand1
follows the string specified by operand2 in the ASCII collating sequence. If it does,
the operator returns a value of 1 (true); otherwise, it returns a value of 0 (false). A
character-by-character comparison is made between operand1 and operand2 until the
two strings do not match. If the character in operand1 that does not match the
character in operand2 follows the character in operand2 in the ASCII collating
sequence, operand1 is said to follow operand2. By definition, if operand2 is null (a
string of zero length) the operator returns a true value. Also, if operand1 and
operand2 match exactly, the operator returns a value of false.
Considerations
The STRING DOES NOT FOLLOW operator can be obtained by preceding the
STRING FOLLOWS operator with the NOT ( ') operator to form the STRING
DOES NOT FOLLOW operator ( ']).
Associated Topics
String Expressions Truth-Valued Expressions
Examples
WRITE "SMITH"]"JONES"
Writes 1 to the current device because "S" follows "J" in the ASCII collating sequence.
W "APPLES"]"APPLE"
Writes 1 to the current device because "S" (the sixth character of operand 1) follows the null
string (the sixth character of operand2) in ASCII collating sequence.
W "AAA"]"AAB"
Writes 0 to the current device because the "A" in the third position of operand1 comes before
"B" in the third position of operand2.
Writes 0 to the current device because the two strings are identical.
W 10]2
Writes 0 to the current device. Although 10 is greater than 2, the STRING FOLLOWS
operator treats the value of all expressions as strings, and in a strict character-by-character-by-
character comparison, 2 follows 1 and the 0 is ignored.
Syntax
operand1]]operand2
Definition
The STRING SORTS AFTER operator tests to see if the string specified by operand1
follows the string specified by operand2 in the subscript collating sequence. If it does,
the operator returns a value of 1 (true); otherwise, it returns a value of 0 (false). The
subscript collating sequence is produced by the single argument form of the
$ORDER function. The value of A]]B ( the string A SORTS AFTER the string B) is
equivalent to the following.
$S(A=+A&(B=+B):A>B,A=+A:B="",B=+B:A'="",1:A]B)
As this formula illustrates, Canonic numbers collate before strings when they are
used as subscripts in local or global variables.
Considerations
The STRING DOES NOT SORT AFTER operator can be obtained by preceding the
STRING SORTS AFTER operator with the NOT ( ' ) operator to form the STRING
DOES NOT SORT AFTER operator ( ']]).
Associated Topics
Collating Sequence
Canonic Numbers
Truth-Valued Expressions
STRING FOLLOWS Operator
String Expressions
$ORDER Function
Examples
WRITE "SMITH"]]"JONES"
Writes 1 to the current device because "SMITH" follows "JONES" in the subscript ordering
sequence.
W 45]]23
Writes 1 to the current device because 45 follows 23 in the subscript ordering sequence.
W 9]]10
Writes 0 to the current device because 9 does not follow 10 in the subscript ordering
sequence. Note that 9]10 would produce a result of 1 because 9 does follow 1 in the ASCII
collating sequence.
W 9]]"05"
Writes 0 to the current device because 9 does not follow the string "05" in the subscript
ordering sequence.
Syntax
operand1-operand2
Definition
The SUBTRACTION operator evaluates each operand as a numeric value and then
computes the algebraic difference of the two values by subtracting operand2 from
operand1.
Considerations
The result of the SUBTRACTION operation is accurate to 16 or 17 digits of
precision, depending on the values of the operands.
Associated Topics
Numeric Expressions
Examples
WRITE 4-2
W 617.343-102.9537
W "456ABC"-"123XYZ"
W "123XYZ"-"ABC"
Writes the value 123 because the string "ABC" evaluates to zero as a number.
Overview
This chapter describes the ANSI-standard M commands and the additional
commands that are provided in the MSM implementation of M.
The M language contains commands that programmers can use to create programs or
routines, as they are referred to in MSM. A command is the method by which the
compiler is directed to perform a specific action. Each command performs a specific
action that is further defined by the operands or arguments associated with the
command.
MSM provides all of the ANSI-standard commands, as well as an extended set of
commands that are specific to MSM. The ANSI-standard commands begin with the
letters A through Y, and the MSM-specific commands begin with the letter Z. For
each command, a single, defined abbreviation for the command can be used in place
of the entire name. Each abbreviation consists of one or more letters of the name and
always begins with the first letter of the name. In the definition of each command, the
abbreviation is shown in bold, and the remainder of the name is shown within braces.
Command names can be specified in uppercase, lowercase, or a combination of
uppercase and lowercase characters.
The following examples illustrate valid abbreviations.
CLOSE
close
C
c
The following sections contain information about the commands provided in MSM.
For each command, the following information is provided: syntax, a description of
the command's function, special considerations, associated topics, and examples. For
additional information on writing M programs, refer to the MSM User's Guide.
Syntax
B{REAK}{:Postcond}
B{REAK}{:Postcond}SP{Expression}
Definition
Postcond Any post-conditional expression.
Expression A numeric expression that is used to enable or disable BREAK
recognition.
The BREAK command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the BREAK command.
A BREAK command without arguments is used to suspend execution of a program.
Before this can occur, MSM's interactive debugging facility must be active. If the
interactive debugging facility is not active, a BREAK command without arguments is
ignored.
When program execution is suspended, the user can enter the interactive debugger
and have full access to the M language for debugging purposes. When the system
enters direct mode as a result of a BREAK command, a message is displayed
indicating that a break occurred, and the system prompts for input with the name of
the program displayed between < and > signs.
At this point, execution of the suspended routine can be resumed using the ZGO
command; QUIT can be entered to exit from the debugging system and return to the
current executing routine; or any M command can be entered. In addition, a question
mark (?) can be entered to obtain a list of commands that can be used within the
interactive debugger.
The BREAK command with an argument is used to control recognition of the break
key (CTRL/C). The break key is used to interrupt execution of a routine. If the value
of the expression is true (evaluates to 1), the break key is recognized. Otherwise, the
break key is treated like any other character. When a BREAK 0 command is issued,
15 (interrupt received) is turned off in $ZA for the current device, if it is a terminal.
Refer to "Using Peripheral Devices" in the MSM User's Guide for additional
information on this bit.
If the BREAK argument has a value of -2 or 2, it is used to control the mode of error
processing that is performed. A value of 2 indicates that the DO/XECUTE stack is to
be discarded before the error is processed. A value of -2 indicates that the
DO/XECUTE stack is preserved and that error processing is performed at the current
execution level. When the system is initialized, a default of -2 is in effect for the
BREAK command. The default setting can be configured through the MODE flags in
the SYSGEN utility.
Examples
Command Explanation
BREAK This command shows an unconditional BREAK.
B:X=3 This command only BREAKs if X=3.
S X=^A(3) I X=0 B K ^A A BREAK is inserted before the global is deleted so that the
programmer may examine the job's status.
B 1 The BREAK character CTRL/C is recognized.
B 0 The BREAK character CTRL/C is not recognized.
B @X Indirection may be used in the BREAK command.
Syntax
C{LOSE}{:Postcond}SPDevice{:Parm}{,...}
Definition
Postcond Any post-conditional expression.
Device An integer expression that indicates which device is to be closed.
Parm One or more expressions separated by colons and enclosed in
parentheses that have meaning specific to the device being closed.
The CLOSE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the CLOSE command.
The CLOSE command is used to release ownership of a device. Multiple devices can
be closed by specifying a list of device number that are separated by commas on the
CLOSE command. If the job issuing the command does not own the specified device,
no action takes place. Ownership of a device is achieved through the OPEN
command.
The device specified can be any valid MSM device, and its number can be specified
using indirection. When the device is closed, MSM makes the principal device the
current device. (The principal device is the device that was used to logon to MSM.)
However, the system does not attempt to OPEN the principal device. When a HALT
command is encountered, all devices owned by the job are closed and returned to the
pool of available devices.
In MSM, Device number 0 indicates the principal device. When a Device number of
0 is specified on a CLOSE command, it is ignored (no action takes place).
Associated Topics
Using Peripheral Devices, MSM User's Guide
Examples
Command Explanation
CLOSE 3 Device 3 is CLOSEd.
C:X=1 Y Device Y is CLOSEd only when X=1.
C 5,X,7 CLOSE multiple devices.
C A+B*3 CLOSE a device using a calculated device number.
C @X Indirection may be used in the CLOSE command.
Syntax
D{O}{:Postcond}
D{O}{:Postcond}SPEntryRef{:Postcond}{,...}
Definition
Postcond Any post-conditional expression.
EntryRef Any valid entry reference.
The DO command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the DO command. For post-conditional expressions on the argument
of the DO command, the argument is skipped if the expression is false.
The DO command is used to call a subroutine within the current routine or a
subroutine in another routine. If the EntryRef does not contain a routine name,
control passes to the label (or label + offset) in the routine containing the DO
command. When the EntryRef contains a routine name, control passes to the label (or
label + offset) in the named routine.
The EntryRef also can be specified as an extended reference. In an extended
reference, the routine name can be preceded with the UCI name, the volume group
name, or both. The format for the extended reference is the same format used for
extended global references. Refer to Chapter 1, "Language Syntax," in this document
for additional information on the format of the extended reference.
If no label (or label + offset) is specified with the routine name, control passes to the
first line of the named routine. The called subroutine terminates when a QUIT
command, which is not within the scope of a FOR command, is encountered or the
physical end of the routine is encountered. When the subroutine terminates, control
passes to the next argument on the DO command or the next command following the
DO command.
In the form without arguments, the DO command invokes a block structured
subroutine at the next higher execution level. The subroutine being invoked must
immediately follow the routine line that contains the argumentless DO command.
Associated Topics
FOR Command
QUIT Command
Block Structured Subroutines
DO with Parameter Passing
Extended Global References
Extended Routine References
Examples
Command Explanation
DO X WRITE Y The subroutine beginning at the line labeled X is
executed, and then the variable Y is written.
D X,Y This is equivalent to DO X DO Y.
D ^PGM W Y Routine PGM is invoked, and then Y is written.
D A,^PGM,^ROU Multiple routine names and labels may be listed as
arguments.
D INT^PROG Routine PROG is invoked beginning at the line labeled
INT.
D:X=1 A^PGM,B,^TEST The list of subroutines is invoked only if X=1.
D ^CEN:A=0,B Routine CEN is invoked if A=0, and then subroutine B
is invoked, regardless of the value of A.
D ^[TST,RMT]LABRSLT Routine LABRST, from the TST UCI in the RMT
volume group, is invoked.
D @X Indirection may be used in the DO command.
D @X^PGM
D ^@XYZ
D @A^@B
D:@A=B @C^@D:@E=@F
S R="^RTN:X=1" D @R
Syntax
D{O}{:Postcond}SPEntryRef(ActualList){:Postcond}{,...}
Definition
Postcond Any post-conditional expression.
EntryRef Any valid entry reference.
ActualList A list of arguments to pass to the called routine.
This form of the DO command allows the user to call a routine and pass it one or
more parameters using MSM's parameter-passing mechanism. Arguments in the
ActualList can be passed to the routine using either call-by-value or call-by-reference
parameter passing.
Normally, all arguments in the ActualList are passed to the routine using
call-by-value. However, if the local variable name is preceded by a period,
call-by-reference is used for the argument. Refer to Chapter 5, "MSM Functions," in
this document for a description of how parameter passing has been implemented in
the MSM system.
The same general considerations and restrictions that exist for extrinsic functions
apply to the DO command with parameter passing. The first line of the routine or
subroutine specified by the EntryRef must contain a label reference with a formal list
(FormalList). If it does not, then a <DPARM> error occurs.
If the specified ActualList is shorter than the FormalList, any variables in the
FormalList that do not have a corresponding entry in the ActualList are undefined.
The converse of this situation is not allowed. If the FormalList is shorter than the
ActualList, a <DPARM> error occurs.
Associated Topics
DO Command
FOR Command
QUIT Command
Block Structured Subroutines
Extrinsic Functions
Command Explanation
DO ^VOLUME(LEN,HEIGHT,DEP) The VOLUME routine is invoked, and the LEN,
HEIGHT, and DEP variables are passed as
parameters.
D PRINT^INVOICE(CUST) The INVOICE routine is invoked at entry point
PRINT, and the CUST variable is passed as a
parameter.
D ^%TRIAREA(BASE/2,HEIGHT) The %TRIAREA routine is invoked and the value
of BASE/2 is passed, as well as the value of the
HEIGHT variable.
D ^%SQRT(.X) The %SQRT routine is invoked, and the address
of the variable X is passed. If the variable in
%SQRT, which points to this address is updated
or KILLed, then the X variable is updated or
KILLed also.
D ^SEARCH(.^CUST) It is illegal to pass global values by reference.
Syntax
E{LSE}
Definition
The ELSE command executes the commands that follow it on the same line only if
the value of the $TEST special variable is 0. If the value is 1, all remaining
commands on the line are ignored, and control passes to the next line in the routine.
There must be at least two spaces between the ELSE command and the commands
that follow it. The $TEST special variable is set by the IF command and by a
command that is used with a timeout (READ, LOCK, ZALLOCATE, OPEN, JOB).
Execution of an ELSE command does not affect the value of $TEST.
An ELSE command that is on the same line as an IF command is not executed unless
an intervening command sets the value of $TEST. If the IF command sets $T to 0,
the ELSE command is never executed. Post-conditional expressions on commands
and arguments, as well as with the $SELECT function, often can be used in place of
the ELSE command.
Associated Topics
$TEST Special Variable
Examples
The following three examples produce the same effect, except that the value of the
$TEST special variable is not altered in the second and third examples.
IF X=1 WRITE "YES"
ELSE WRITE "NO"
WRITE:X=1 "YES" WRITE:(X=1) "NO"
WRITE $S(X=1:"YES",X'=1:"NO")
Syntax
F{OR}
F{OR}SPLocalVar=ForParm{,...}
Definition
LocalVar An expression that evaluates to a local variable name.
ForParm A value used to describe the repetition of the loop. It must be in
one of the following forms:
Expression
Begin:Incr
Begin:Incr:End
Expression Any valid expression.
Begin A numeric expression that is the starting value of the loop.
Incr A numeric expression whose value is added to the begin value
for each repetition.
End A numeric expression that is the ending value for the loop.
The FOR command is used to control repeated execution of the commands that
follow it on the same line. All commands after the FOR command (starting with the
first command after the FOR and through the last command on the same line as the
FOR) are referred to as the scope of the FOR command. Although arguments on the
FOR command cannot be listed, the ForParm can be listed and the different types of
ForParm that are allowed can be intermixed. Although argument indirection is not
permitted on the FOR command, name indirection is permitted in the Begin, Incr,
and End portions of the ForParm.
Within a FOR command, each ForParm causes the local variable to be given a
specified sequence of values, and the scope of the FOR command is executed once
for each value. Successive ForParm sequences continue this process in left-to-right
order. Any expression occurring in the local variable (for example, in a subscript or
in indirection) is evaluated only once at the beginning of the FOR command prior to
execution of any ForParm.
If the FOR command is specified without any operands (argumentless form), the
command continuously loops until a QUIT or GOTO command is encountered within
the scope of the FOR command.
The following sections describe how each ForParm format specifies and controls the
values of the local variables and the sequence of executions of the scope of the FOR
command.
Considerations
Within the scope of the FOR command, the code being executed can modify the
value of the local variable. When this is done, execution continues until the end value
is exceeded.
Associated Topics
DO Command
QUIT Command
Command Explanation
FOR I=1:1 WRITE I QUIT:I>2 W "*" The output is 1*2*3.
F I=1:1:3 W I The output is 123.
F I=3:-2:-2 W I The output is 31-1.
F I=5,3.4,7,9 W I The output is 53.479.
F Q:$DATA(^LOCK) This routine executes until ^LOCK
exists. In this example, the FOR
command is followed by at least two
spaces.
F I=.4,1:2:5,9,10:1 DO A IF I>15 QUIT A is executed 12 times.
F I=1:1:2 F J=2:2:6 W I,"@",J,"*" The output is the string:
1@2*1@4*1@6*2@2*2@4*2@6*
F I=1:1:3 F J=10:10:30 Q:I*J>30 W The output is the string:
I,"@",J,"*"
1@10*1@20*1@30*2@10*3@10*
F I=3:5:0 W I Nothing is written. The final value
of I is 3.
F I=.01:.0001:.02 D A This executes A 101 times.
F I=X:Y:Z D A Routine A is called once for each
iteration of the loop.
F I=1:2:10 S I=I-1 W I Changing the value of the local
variable which is used as the index
is permitted. The output is
0123456789.
S Z=10 F I=2:2:Z S Z=Z-1 D A Because the ending value of the
loop is computed before the scope is
executed, A is executed 5 times.
F I="TEST",X,3:4:5 ... When the simple form of the FOR
parameter is used, the index may be
given non-numeric values.
F I=X:Y:Z F J=A:B:C G LCS The GOTO exits from all nested
FORs.
F I=@X:1:3 D @B Name indirection can be used on the
FOR command.
F @i=@X:@Y:@Z D @B FOR using indirection
Syntax
G{OTO}{:Postcond}SPEntryRef{:Postcond}{,...}
Definition
Postcond Any post-conditional expression.
EntryRef Any valid entry reference.
The GOTO command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the GOTO command. For Postcond expressions on the arguments of
the GOTO command, the argument is skipped if the expression is false. In contrast to
the DO command, when arguments are listed, no more than one argument actually
transfers control.
The GOTO command is used to pass control to a line of code in the current routine
or to a line of code in a different routine. If the EntryRef does not contain a routine
name, control passes to the label (or label + offset) in the routine that contains the
GOTO command. When the EntryRef contains a routine name, control passes to the
label (or label + offset) in the named routine. If no label (or label + offset) is
specified with the routine name, control passes to the first line of the named routine.
The GOTO command can be used in a block structured subroutine, but only under
the following condition: there can be no routine lines at a lower execution level (with
fewer dots at the beginning of the line) between the GOTO command and the label
which is the GOTO argument. In other words, GOTO is valid only within its own
block structured subroutine. If this rule is violated, an error is not generated, but the
routine executes in an unpredictable manner.
Associated Topics
Entry Reference
Execution Level
Block Structure Subroutine
Command Explanation
GOTO XYZ Execution continues at the start of the line
labeled XYZ in the current routine.
GOTO ^PGM Execution switches from the routine containing
the GOTO to the first line of the routine PGM.
G CC+2^ABC Execution switches to the second line after the
line labeled CC in routine ABC.
G 13^GRAY:A=1 If and only if A=1, execution switches to the
line labeled 13 in routine GRAY.
G:A=1 13^GRAY This is equivalent to example 4.
G ^ADM:A=0,X^CEN If A=0, then execution switches to the first line
of routine ADM; otherwise, execution switches
to the line labeled X in routine CEN.
G:A=1 AAA:B=2,13:D=4 This line is equivalent to G AAA:A=1&(B=2)
G 13:A=1&(D=4).
G @X There are many opportunities to use indirection
G ^@B
G A^@B
within the GOTO command. The first and last
G @A^B examples are using argument indirection. The
G @A^@B others illustrate name indirection
S A="^RTN:X=1" G @A
G:X=@Y @A+@C+D^@PGM:@E=@F If execution switches, the line at which
execution continues is @C+Dth line after label
@A.
Syntax
H{ALT}{:Postcond}
Definition
Postcond Any post-conditional expression.
The HALT command is executed if the Postcond expression is true, or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the HALT command.
The HALT command is used to terminate the job that issues the command. When the
job halts, all open devices are closed, all variables that are locked as a result of
LOCK or ZALLOCATE commands are unlocked, and the partition associated with
the job is released.
Examples
Command Explanation
HALT This is an unconditional HALT command.
H:A=1 WRITE "TEST" If A=1, the process HALTs. Otherwise, execution
continues and TEST is written to the current device.
Note that there must be at least two spaces after the
HALT command in this example.
H:A=@B Indirection may be used in the post-conditional
expression.
Syntax
H{ANG}{:Postcond}SPExpression
Definition
Postcond Any post-conditional expression.
Expression A numeric expression.
The HANG command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the HANG command.
The HANG command is used to suspend execution of a job for a specified period of
time. The time interval is specified in whole seconds, fractions of a second, or a
combination of whole seconds and fractions of a second. After the time interval
expires, execution resumes with the next command following the HANG command.
If the time interval is 0 or less than 0, the HANG command has no effect.
Examples
Command Explanation
IF $PIECE($HOROLOG,",",2)<X HANG 3 If the number of seconds after
midnight is less than X, then
execution hangs for 3 seconds.
H:I=3 10 WRITE ! If I=3, a 10-second HANG is
executed before the WRITE.
H @X Indirection may be used in the HANG
H:$E(@A,B,@C) X+@Y+Z
command.
H 4.2 Fractional values may be used in the
HANG command; however, the
fractional part is ignored in all
versions of MSM.
Syntax
I{F}
I{F}SP{TruthExp{,...}}
Definition
TruthExp An expression that evaluates to either true or false.
In the argumentless form, the IF command executes the commands that follow it on
the same line, only if the value of the $TEST special variable is 1 (true). If the value
is 0 (false), all remaining commands on the line are ignored, and control passes to the
next line in the routine. The $TEST special variable is set by the IF command and by
a command that is used with a timeout (READ, LOCK, ZALLOCATE, OPEN, JOB).
Execution of an argumentless IF command does not affect the value of $TEST.
In the form of the IF command with an argument, the additional commands on the
line are executed only if the value of the TruthExp is 1. If the value is 0, all remaining
commands on the line are ignored and control is passed to the next line in the routine.
When this form of the IF command is used, the $TEST special variable is assigned
the value of the truth-valued expression.
When multiple arguments, separated by commas, are specified on the IF command,
they are evaluated in left-to-right order. If all of the arguments are true (truth value of
1), the remainder of the line is processed. If any of the arguments are false, the
remainder of the line is ignored.
Associated Topics
Truth-Valued Expressions
Command Explanation
IF X=1 WRITE X The code to the right of the IF command is executed
only if X=1.
I Y SET Z=3 The code to the right of the IF command is executed
only if the numeric interpretation of the value of Y is
non-zero.
I X=2,Y=2 DO 3 The following are equivalent: IF X=2 IF Y=2 DO 3
IF X=2&(Y=2) DO 3
I X,^A(Y) GOTO 3 The following code is similar: IF X&(^A(Y)) G 3.
However, the side effects are different because the
latter always evaluates ^A(Y), while the former may
not, depending on the value of X.
I X?1N2A!(Y=2) Complex expressions occur frequently in IF
commands.
IF X=1 W !,"TEST" If X=1, this code writes TEST ARGUMENTLESS.
ELSE W !,"EXAM"
IF W "ARGUMENTLESS"
Otherwise, it writes EXAM.
Syntax
J{OB}{:Postcond}SPJobParm{,...}
where JobParm is:
EntryRef{|UCI{,Vol{,Sys}}|}{:{({PartSiz}{:SymFlag})}{:TimeOut}}
Definition
Postcond Any post-conditional expression.
EntryRef Any valid entry reference.
UCI The name of the user class identifier (UCI) that contains the
program.
Vol The name of the volume group that contains the UCI and program.
Sys The system or node name on which the program will be run.
PartSiz The partition size in 1K blocks.
SymFlag A flag indicating whether or not the local symbol table of the current
job is to be copied to the new job.
TimeOut A timeout value.
The JOB command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the JOB command.
The JOB command is used to start a new M process (a job). The process that is
started is referred to as a background job in MSM. When the JOB command is
executed, the system assigns a new partition to the job if one is available. The system
then internally performs a DO command with the specified EntryRef as its argument.
The new process executes in parallel with the process that contain the JOB command.
A user-class identifier (UCI), volume group (Vol), and system name (Sys) can be
appended to the EntryRef to indicate where the routine specified in the EntryRef is
stored. Alternatively, the UCI parameter can be an expression that evaluates to a
string containing the UCI, Vol, and Sys names separated by a comma. For backwards
compatibility, the ANSI-standard vertical bars ( | ) can be used in place of the left
bracket ( [ ) and right bracket ( ] ) characters.
Although the Vol and Sys parameters are both optional, Sys can be used only if Vol
also is specified. The purpose of the Sys parameter is to resolve the ambiguity that
occurs when a remote volume group is mounted. If Sys is not specified in this case,
the job executes on the local system.
Associated Topics
JOB with Parameter Passing
Entry Reference
$ZB Special Variable
Command Explanation
JOB X New process is initiated with the current
routine, and execution begins with the line
labeled X.
J ^A,^B,^C In turn, a new process is initiated and
execution begins at the first line of routines
A, B, and C, respectively. A total of 3 new
processes are initiated by this command. It is
equivalent to JOB ^A JOB ^B JOB ^C.
J ^NAME::10 GOTO ERR:'$T An attempt is made to start a new process at
the first line of routine NAME. The
command waits up to 10 seconds for the new
process to begin. If it does, $T is 1.
Otherwise, $T is 0, and execution switches to
the line labeled ERR.
J ^NAME::10 ELSE G ERR This is equivalent to example 3.
J:N>6 ^TEST Post-conditionals may be used.
J START^CUSLOOK:(24) A new process is initiated with a 24K
partition. Execution begins at label START
in routine CUSLOOK.
J ^NAME|"FMR","VAB"| A new process is initiated and execution
begins at the first line of routine NAME in
the UCI called FMR on volume group VAB.
J ^NAME:(25:1) A new process is initiated and execution
begins at the first line of routine NAME with
a 25 KB partition and a copy of the current
job's local symbol table.
J @X Argument indirection may be used.
J ^|"PRD,APP,BAS"|NAME:(:1) A new process is initiated on node BAS,
regardless of whether or not the APP volume
group is remotely mounted. Although the
system indicates that the symbol table is to
be copied, this feature is not honored (the
parameter is ignored) for cross-system JOB
commands.
Syntax
J{OB}{:Postcond}SPJobParm{,...}
where JobParm is:
EntryRef(ActualList){|UCI{,Vol{,Sys}}|}{:{({PartSiz} {:SymFlag})}{:TimeOut}}
Definition
Postcond Any post-conditional expression.
EntryRef Any valid entry reference.
ActualList A list of arguments to pass to the new job.
UCI The name of the user-class identifier (UCI) that contains the program.
Vol The name of the volume group that contains the UCI and program.
Sys The system or node name on which the process is run.
PartSiz The partition size in 1K blocks.
Sym Flag A flag that indicates whether the local symbol table of the current job
is to be copied to the new job.
TimeOut A timeout value.
This form of the JOB command allows the user to pass one or more parameters to the
new job using the MSM parameter-passing facilities. All entries in the ActualList are
passed to the new job using call-by-value parameter passing. The M language does
not support call-by-reference parameter-passing for the Job command. If a period is
specified before a local variable name in the ActualList, a <DPARM> error occurs.
Refer to Chapter 5, "MSM Functions," in this document for additional information on
parameter passing.
The same general considerations and restrictions that exist for extrinsic functions also
apply to the JOB command with parameter passing. This means that the first line of
the routine or subroutine specified by the EntryRef must contain a label reference
with a Formal List (FormalList). If it does not, a <DPARM> error occurs.
If the specified ActualList is shorter than the FormalList, any variables in the
FormalList that do not have a corresponding entry in the ActualList are undefined.
The converse is not allowed. If the FormalList is shorter than the ActualList, a
<DPARM> error occurs.
Associated Topics
Entry Reference
DO Command with Parameter Passing
JOB Command
Extrinsic Functions
Command Explanation
JOB ^TASKMAN(FLAGS) The TASKMAN routine is invoked, and the
FLAGS variable is passed as a parameter.
J PRINT^INV(CUST,YTD/12) The INV routine is invoked at entry point PRINT.
The value of the CUST variable is passed as the
first parameter, and the value of YTD/12 is passed
as the second.
J ^UPDATE(X)["VAH"] The UPDATE routine is invoked in UCI "VAH",
and the value of the variable X is passed.
J ^REPORT["PRD","CPU"] The REPORT routine is invoked in UCI "PRD"
within volume group "CPU". The specified volume
group may be on another machine if MSM-NET is
in use.
Syntax
K{ILL}
K{ILL}{:Postcond}SPVariable{,...}
K{ILL}{:Postcond}SP(LocalVar{,...})
Definition
Postcond Any post-conditional expression.
Variable A local or global variable name.
LocalVar An unsubscripted local variable name.
The KILL command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the KILL command.
The KILL command is used to delete local variables, global variables, or a
combination of local and global variables.
There are three forms of the KILL command.
Argumentless form KILL ALL
Variable,... form Selective (inclusive) KILL
(LocalVar,...) form Non-selective (exclusive) KILL
In the KILL ALL (argumentless form), all local variables that have not been hidden
by the NEW command are deleted. After execution of this form, the local symbol
table is empty.
In the selective KILL form, only the local or global variables specifically named as
arguments of the KILL command are deleted. The local and global variable names
can include subscripts.
In the exclusive KILL form, all local variables are deleted except the named local
variables and their descendants. Global variable names and subscripted local variable
names may not be specified in an exclusive KILL.
When a variable is deleted, all of its descendants also are deleted. If the specified
variable does not exist, no action occurs. When arguments are listed, the selective
KILL form can be mixed with the exclusive KILL form.
Associated Topics
Variables
NEW Command
Command Explanation
KILL X Local variable X is killed.
K X,Y,^A(3,4) Local variables X and Y and global variable
^A(3,4) are killed.
K (A) All local variables except A and its descendants
are killed.
K (X,Y,ZZ1,%NAM) All local variables except those named and their
descendants are killed.
K SET X=$S The argumentless form causes all local variables
to be killed. After execution of this line, X is the
only local variable defined.
K:Y=1 ^T(Y) If Y=1, then ^T(1) is killed. All forms of KILL
may have post-conditional expressions on the
command.
K ^CUS The entire ^CUS global is killed.
K @A Indirection may be used in the KILL command.
K X,@Y,Z
K:@Y=Z CUS(NUM,@NODE)
Syntax
L{OCK}
L{OCK}{:Postcond}SP{(+-}Variable{:TimeOut}{,...}
L{OCK}{:Postcond}SP{(+-}(Variable,...){:TimeOut}
Definition
Postcond Any post-conditional expression.
Variable A local or global variable name.
TimeOut A timeout value.
The LOCK command is executed if the Postcond expression is true or if it is not
supplied. If it is supplied and it is false, execution moves to the next command after
the LOCK command.
The LOCK command is used to lock both local and global variables. The MSM
system maintains a table of all locked variables, which is referred to as the LOCK
table. When a user attempts to lock a variable, the system searches the table to
determine if another user already locked the variable. If the variable is locked, the
new lock is not granted.
When a lock is requested for a local variable, the lock is known throughout the
system and no other system user can lock the variable. When the lock is for a global
variable, the lock is known only within the UCI, and only users in the same UCI are
prevented from locking the variable.
When a variable is unlocked, its name is removed from the LOCK table, thereby
allowing other users to lock the variable. LOCK is only a convention. Rather than
prevent users from accessing a locked variable, LOCK prevents them from locking
the same variable. The system does not require the variable that is to be locked to
actually exist or have data. If all users follow the same conventions, simultaneous
updates to the same data can be prevented.
The LOCK command functions in either of two ways.
In the simple form, the user specifies one or more variables to lock, which replace the
entire list of previously locked variables. The LOCK command first releases all
existing locks that are owned by the job. Any jobs that were suspended while waiting
for a locked variable can be resumed. No new variables are locked.
The LOCK command then attempts to lock all of the variable names in a left-to-right
order. No variables are locked unless all of the variables in the argument can be
locked.
In the other form, in which each variable name or the list of variables is preceded by
a plus sign (+) or minus sign (-), one or more variables are added to or removed
from the list of currently locked variables. This is known as an incremental LOCK.
Considerations
When incremental LOCKs with a plus sign are used and the same variable is
specified, it is LOCKed multiple times. To remove the variable from the LOCK list,
multiple incremental LOCKs with a minus sign or a lock with no arguments are
required.
Associated Topics
ZALLOCATE Command
ZDEALLOCATE Command
Command Explanation
LOCK ^TST Between the time execution is resumed after this
LOCK, and the time of execution of the next LOCK
by this process, no other process is able to execute
an argument of LOCK containing the unsubscripted
global name ^TST or any subscripted global name
whose name part is TST. In addition, any variables
previously LOCKed by the process are unLOCKed.
L SET X=1 The argumentless LOCK command unlocks all
previous locks held by this process.
L (^P(1,2),^Q(3)) Between the time execution is resumed after the
LOCK, and the time of execution of the next LOCK
by this process, no other process is able to lock any
of the following:
^P ^P(1,2) ^P(1,2,3)
^Q ^Q(3) ^Q(3,4,5)
^P(1)
However, any process can LOCK any of the
following variables:
^P(2) ^P(1,3,4) ^Q(4)
L D(1):3 GOTO A:'$TEST An attempt is made for an interval of 3 seconds to
LOCK D(1). If it is successful, $T is 1. Otherwise,
$T is 0 and execution continues with line A.
L +(A,^GL) Add LOCKs for the 2 variables to the list of
variables previously LOCKed by this job.
L +TEST,-B(1,2) LOCK the variable TEST and unlock the variable
B(1,2) without affecting other LOCKs for this job.
L D(1):3 ELSE G A This is equivalent to example 4.
L:X=1 ^EF(^A(5)) The LOCK command can be post-conditionalized.
Appearance of a global name does not affect the
naked indicator unless, as in this example, it occurs
in an evaluated expression. Here it is a subscript;
other such possibilities are in post-conditionals and
indirection. After this command, the naked indicator
is set to ^A(.
L +^TST,-^Q(3),+A This command adds ^TST to the list of variables that
are locked, then removes ^Q(3) from the list, and
then adds A.
L +(^TST,A),-^Q(3) This command adds ^TST and A to the list of
variables that are locked, and then removes ^Q(3)
from the list.
L @A Indirection may be used in the LOCK command.
L:@B=C (X(@A),@B)
Syntax
M{ERGE}{:Postcond}SPDestVar=SourceVar{,...}
Definition
Postcond Any post-conditional expression.
DestVar Either a local or global variable name, optionally with subscripts.
SourceVar Either a local or global variable name, optionally with subscripts.
The MERGE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the MERGE command.
The MERGE command copies a specified local or global variable (SourceVar) to a
specified local or global variable (DestVar). It also copies all of the descendants of
the specified SourceVar into corresponding descendants of the specified DestVar.
The copy operation can be defined as a series of rules.
For explanatory purposes, it is assumed that DestVar is represented as A(i1,i2, ... ,ix),
where x '< 0, and that SourceVar is represented as B(j1,j2, ... ,jy), where y '< 0. By
definition, if x or y is 0, the corresponding variable is unsubscripted. Similarly, if x or
y is greater than 0, the corresponding variable contains one or more subscripts. Given
these assumptions, the following rules determine the actual data that is copied by the
MERGE command.
If $DATA (B(j1,j2, ..., jy) has a value of 1 or 11, the value of SourceVar is given to
DestVar.
For every occurrence of z such that z > 0, and $DATA(B(j1,j2, ... ,jy+z) has a value of
1 or 11, the value of B(j1,j2, ... ,jy+z) is given to A(i1,i2, ... ,ix,jy+1,jy+2, ... ,jy+z)
The current value of the naked indicator is modified by the MERGE command. The
new value assigned to the naked indicator is the same as if
$DATA(SourceVar)#10=1 and the command SET DestVar=SourceVar were
executed (the naked indicator is determined by the value of DestVar).
It is erroneous for the DestVar to be a descendant of the SourceVar, or for the
SourceVar to be a descendant of the DestVar. If either occurs, MSM generates an
error.
Considerations
The duration of the MERGE command can be lengthy. If the MSM system is
interrupted during execution of the MERGE command (for example, if there is a
system failure or the BREAK key is pressed), only part of the data may be merged.
Associated Topics
SET Command
$DATA Function
$ORDER Function
Command Explanation
MERGE ^A=^B All of global B is merged into global A.
M ^CUST("ABC",3,5)=CUST Merge the local variable CUST into the global
variable CUST(ABC,3,5).
M A(1)=A(2) All of local A(2) are merged into the local A(1).
M A(1)=A(1,2) This is an illegal operation because A(1,2) is a
descendant node of A(1).
M @X=Y(1,2,3) Indirection is often used in the MERGE
M A(4,5,6)=@B
M @A@(1,2)=B
command.
Syntax
N{EW}
N{EW}{:Postcond}SPVar{,...}
N{EW}{:Postcond}SP(LocalVar{,...})
Definition
Postcond Any post-conditional expression.
Var Any unsubscripted local variable name or selected special
variables ($ETRAP, $ESTACK, $TEST, and $ZREFERENCE).
LocalVar An unsubscripted local variable name.
The NEW command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the NEW command.
The NEW command is used to make temporary copies of local variables. When a
temporary copy is created, the old variable, its value, and the values of all its
descendants are copied onto a stack. The original variable then is removed from the
local symbol table (KILLed). When a QUIT command is encountered on the same
execution level as the NEW command was executed, the stacked values are restored
to the local symbol table.
There are three forms of NEW.
Argumentless form NEW ALL
Var,... form Selective (inclusive) NEW
(LocalVar,...) form Non-selective (exclusive) NEW
In the NEW ALL (argumentless form), all local variables are stacked and a KILL
ALL (argumentless KILL) then is performed. After execution of this form, the local
symbol table is empty.
In the selective NEW form, only the local variables or selected special variables
specifically named as arguments of the NEW command are stacked. For local
variables, a selective KILL is performed using the same argument. Local variable
names may not include subscripts. If the name includes subscripts, an error occurs.
In the exclusive NEW form, all local variables are stacked except the named local
variables and their descendants. An exclusive KILL is performed using the same
argument. Subscripted local variable names cannot be specified in an exclusive
NEW.
An inclusive NEW on a selected special variable makes a copy of the special
variable. This copy is retrieved (unstacked) when the corresponding QUIT command
is encountered. In the case of $ESTACK, the new command also resets it to zero.
Associated Topics
KILL Command
QUIT Command
$ETRAP Special Variable
$ESTACK Special Variable
$TEST Special Variable
$ZREFERENCE Special Variable
Examples
Command Explanation
NEW X This routine stacks local variable X.
NEW (A,B) This routine stacks all local variables except A
and B and their descendants. On a QUIT, the
system does a KILL (A,B) and then unstacks
the hidden A and B variables.
NEW The argumentless form of NEW stacks all
local variables.
N:X=1 X This routine stacks local variable X and all of
its descendants if and only if X=1.
N @X Indirection can be used in the NEW
N A,@B,C
N:@B=C (A,@B)
command.
The following routine illustrates the NEW stacking process. The output of this routine is
OK.
NEWTEST;
SET X=1 DO LABEL
IF X=1,Y=4 WRITE "OK"
QUIT
LABEL NEW X
S X=2,Y=X*2 QUIT
N $ESTACK,$TEST,$ZREFERENCE Stacks the current values of $ESTACK,
$TEST, and $ZREFERENCE. The current
value of $ESTACK is reset to zero.
Syntax
O{PEN}{:Postcond}SPDevice{{:Parm{:TimeOut}}}{,...}
Definition
Postcond Any post-conditional expression.
Device An integer expression that indicates which device is to be
OPENed.
Parm One or more expressions separated by colons and enclosed in
parentheses that have meaning specific to the device being
opened.
TimeOut A timeout value.
The OPEN command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the OPEN command.
The OPEN command is used to acquire exclusive ownership of a device. For the
OPEN command to be successful, the device must not be owned by any other
partition. The device specified can be any valid MSM device number. The
parameters specified on the OPEN command are specific to the device being
OPENed. When a user logs onto MSM, the logon device is designated as the
principal device (its value is assigned to $PRINCIPAL). This device is OPENed by
the system and does not need to be OPENed by the user. All other devices must be
OPENed before they can be accessed with a USE command.
If the device is not available, then the process issuing the OPEN command is
suspended until it becomes available. An indefinite suspension of the process can be
avoided by including the TimeOut parameter. When a timeout is specified, execution
is resumed after the specified interval even if the device is not available. The $TEST
special variable then can be interrogated to determine whether a device was OPENed.
If the device was successfully OPENed, the value of $TEST is 1 (true); otherwise it
is 0 (false). If the timeout value is 0 or less then 0, no suspension occurs and the
value of the $TEST special variable is set to indicate the success or failure of the
OPEN command.
Associated Topics
USE Command
ZUSE Command
$PRINCIPAL Special Variable
Using Peripheral Devices, MSM User's Guide
Command Explanation
OPEN 4 Ownership of device 4 is obtained. If another process already
owns device 4, this process hangs until the device is available.
O 4,X,Y Similarly, devices 4, X, and Y are OPENed in turn.
O X::3 G A:'$T The process attempts to OPEN device X for up to 3 seconds. If it
is successful, $T is 1 (true). Otherwise, $T is 0 (false) and
execution continues at line A.
O X::3 ELSE G A This is equivalent to example 3.
O:X=1 A,B,C The OPEN command may be post-conditionalized.
O 3:(132::::1) Device-specific parameters may be supplied on the OPEN. In this
case, the right margin is set to 132 and echo is turned off.
O @X Indirection can be used in arguments of the OPEN command.
Syntax
Q{UIT}{:Postcond}
Q{UIT}{:Postcond}SPExpression
Definition
Postcond Any post-conditional expression.
Expression Any expression used to return a value.
The QUIT command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the QUIT command.
The QUIT command is used to terminate execution of any of the following: a
subroutine that was invoked with a DO command, an XECUTE command, a FOR
command, or an extrinsic function. When a QUIT command is encountered that is
not on the same line as a FOR command, it causes an exit from the subroutine that
was initiated by a DO or XECUTE command or an extrinsic function call. An
XECUTE command can be thought of as a one-line subroutine. The QUIT returns to
the calling routine and continues execution with the next command that follows the
DO or XECUTE command or extrinsic function call that invoked the subroutine.
When the QUIT command is on the same line as a FOR command, it terminates the
innermost FOR command. If the line containing the QUIT has only one FOR,
execution of the QUIT terminates execution of the line. If the line has more than one
FOR, execution of the QUIT causes termination of the innermost FOR and causes
termination of the current repetition of the second-from-innermost FOR.
When a routine called as an extrinsic function terminates, the QUIT must include an
Expression as an operand. If it does not, an error occurs. If the Expression evaluates
to an object reference, the QUIT command returns the object reference rather than
the value associated with the default property. Extrinsic functions are permitted to
return object references, and the calling context decides whether to invoke the default
property. This differs from object references in most other contexts in which the
default property is invoked.
Upon termination, the system returns to the argument immediately following the one
that contains the extrinsic function reference. If the QUIT includes an expression and
the routine was not called as an extrinsic function, an error occurs.
Considerations
Execution of the last line of a routine that does not transfer control to another
location (falls off the end of a routine) causes an implicit QUIT to be performed.
Examples
Command Explanation
IF X>3 QUIT WRITE Y
Syntax
R{EAD}{:Postcond}SPStringLit
R{EAD}{:Postcond}SPFormat
R{EAD}{:Postcond}SPVariable{#Length}{:TimeOut}
R{EAD}{:Postcond}SP*Variable{:TimeOut}
Definition
Postcond Any post-conditional expression.
StringLit A string literal.
Format A formatting character or mnemonic namespace value that
indicates the control characters to be sent to the device.
Variable A local or global variable name.
#Length An integer expression preceded by a # (pound sign) that
indicates the number of characters to read.
*Variable A local or global variable name preceded by an * (asterisk).
TimeOut A timeout value.
The READ command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the READ command.
The READ command is used to accept input characters from the current device.
Optionally, the READ command can send an output sequence to the device before
accepting input. The different types of argument forms can be listed on the READ
command to achieve the desired results. Each argument form is described below.
StringLit
The specified string literal is sent to the current device, and the value of the $X
special variable is adjusted accordingly. If the current device does not allow output,
an error occurs and the value of $X is not updated.
Format
The specified formatting characters or mnemonic namespace characters are sent to
the current device, and the values of $X and $Y are adjusted accordingly. Multiple
formatting characters can be specified in a single argument of the READ command.
If the current device does not allow output, an error occurs and the values of $X and
$Y are not updated.
Variable{#Length}{:TimeOut}
In this form, the system reads a string of characters from the current device and
assigns the string to the specified local or global variable. If the #Length field is
specified, the maximum length of the input string is the value specified by the Length
field. If the Length field is not specified, a length of 255 characters is assumed for
terminal devices. For non-terminal devices, no default value is assumed.
Considerations
The MSM system supports typeahead, a feature that allows the user to type
information into the system before the corresponding READ operation is performed.
Information that is received in this manner is stored in the typeahead buffer. The
typeahead buffer is discarded if the READ command includes a Format or StringLit
argument.
The $X special variable is updated not because input is received, but rather because
data is echoed back to the input device. The ECHO feature affects only terminal
devices and can be disabled via the USE command.
Associated Topics
$TEST Special Variable
$X Special Variable
$Y Special Variable
Format Characters
Using Peripheral Devices, MSM User's Guide
Command Explanation
READ X A data string is entered into local
variable X.
R X,Y,Z Data strings are entered into local
variables X, Y, and Z.
R "PATIENT? " ,^X The message PATIENT? appears on
the current device, and then execution
waits for data to be entered, after which
it is placed in global X.
R !!,"FIRST?",X,?30,"SECOND?",Y This code causes two carriage return
line feeds to occur on the current
device. The message FIRST? is then
displayed. After data is entered into
variable X, the device spaces to column
30 and the message SECOND? is
displayed. Data may then be entered
and read into variable Y.
R "TIMING?",X:10 GOTO A:'$T After displaying TIMING?, the job
waits for up to 10 seconds for input. If
the RET key is pressed during that time
period, $T is set to 1. Otherwise, $T is
0, X may contain partial input, and
execution continues at A. If no
characters have been entered, X
contains the empty string.
R "TIMING?",X:10 ELSE G A This is equivalent to the preceding
example.
R *X,*Y,*Z This form of the read returns single
characters that have been converted to
their ASCII equivalent numeric codes.
If the characters AB RET are entered,
then the following values result:
X=65
Y=66
Z=13
R *X:10 E G A The asterisk form may also use a
timeout. If the timeout expires without
a character having been entered, X has
the value -1, and execution continues at
A.
R X#10 Up to 10 characters can be entered
before the READ terminates. The
READ terminates after the tenth
character is entered or when a RET or
ESC is entered.
Syntax
S{ET}{:Postcond}SPVariable=Expression
S{ET}{:Postcond}SP(Variable{,...})=Expression
Definition
Postcond Any post-conditional expression.
Variable A local or global variable name, or the $PIECE or
$EXTRACT function containing a local or global variable
name.
Expression Any expression.
The SET command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the SET command.
The SET command is used to assign the value of an expression to one or more local
variables. When multiple variables are to be assigned the same value, their names are
separated by commas and enclosed in parentheses. Execution of the SET command
occurs in the following order:
1. Any indirection or subscripts that appear in the argument are evaluated in a left-
to-right order.
2. The Expression is evaluated according to the specified rules.
3. Each Variable is evaluated one at a time in a left-to-right order ,and the value of
the Expression is assigned to it. When the value is assigned, any of the following
conditions can occur.
If a naked reference was used to specify the Variable to which the value is to be
assigned, the naked indicator is used to produce the full reference. In turn, the full
reference that is generated sets the naked indicator to a new value.
If the Variable includes subscripts and the specified node does not exist, the system
creates the node and the minimum number of ancestor nodes required to provide a
path to the new node. When the ancestor nodes are created, they are defined so that
they have descendants but no data value (when the $DATA function is applied to the
created ancestor node, its value is 10).
Considerations
The $PIECE and $EXTRACT functions can be used in place of the Variable name
on the left side of the equal sign on a SET command. When this form is used, the
appropriate piece or substring is assigned the value of the Expression. The string
specified in the $PIECE or $EXTRACT function can be extended if necessary to
satisfy the function. For $PIECE, the string is padded with empty pieces using the
specified delimiter. For $EXTRACT, the string is padded with blanks. Some special
variables in MSM can be assigned values using the SET command. In particular, the
values of $ECODE, $ETRAP, $X, $Y, $ZNAME, and $ZTRAP can be modified
with the SET command. The SET $X and SET $Y do not move the cursor.
Associated Topics
Variables
Objects
Binary EQUALS Operator
ZSETOBJ Command
$EXTRACT Function
$PIECE Function
$ECODE Special Variable
$ETRAP Special Variable
$X and $Y Special Variables
$ZERROR Special Variable
$ZNAME Special Variable
$ZTRAP Special Variable
Examples
Command Explanation
SET ^X=Y The value of the unsubscripted variable Y is
assigned to the unsubscripted global
variable ^X.
S ^A(1,2)=B(3,4) The value of the subscripted variable Y is
assigned to the subscripted global variable
^X.
S ^A(1)=X,B(4)=D,^C="TEST",Z=^D Multiple arguments of SET.
S ^(2)=^C(X,2)+1 Because the expression to the right of the =
is evaluated before the variable name to its
left is determined, the naked reference ^(2)
denotes ^C(X,2). If the line had been:
S ^C(X,2)=^(2)+1
the meaning of the naked reference would
depend on the state of the naked indicator
prior to execution of the SET.
S (A,B,C)=123 This is a "multiple" set. All variables in the
parentheses are set to the same value.
S (A,B,C,D)=0,^A(3)=W,(^A(3,4), Multiple and single SETs may be mixed in
^B(5))=I
one command.
S ^A(5)=10,B(^(3))=^C(4) When subscripts occur to the left of the =,
they are evaluated before the right side
expression. Thus, this line is equivalent to:
S ^A(5)=10,B(^A(3))=^C(4)
Syntax
TC{OMMIT}{:Postcond}
Definition
Postcond Any post-conditional expression.
The TCOMMIT command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the TCOMMIT command.
The TCOMMIT command indicates to the system that the current transaction or
subtransaction is complete. If the $TLEVEL special variable is 1, TCOMMIT
performs a commit of the transaction (applies all associated SETs and KILLs to the
database) and sets the $TRESTART special variable to 0.
If $TLEVEL is greater than 0, TCOMMIT subtracts 1 from $TLEVEL. If $TLEVEL
is 0, TCOMMIT generates an error.
Considerations
In MSM Version 4.3, the commands and special variables associated with the M
Development Committee (MDC) Type A Standard for transactions are only partially
supported; however, the syntax is fully supported.
In addition, if the after-image journal is applied to the database (rolling forward a
bulletproof database after a system failure or applying the journal after a database
restore) the system attempts to apply only complete transactions (SETs and KILLs
bracketed by TSTART and TCOMMIT). A future release of MSM will fully support
transaction processing.
Associated Topics
TRESTART Command
TROLLBACK Command
TSTART Command
$TLEVEL Special Variable
$TRESTART Special Variable
Examples
Command Explanation
TCOMMIT This routine indicates to the system that the current transaction
should be committed.
TC:UPDATE=1 This routine commits the transaction if and only if UPDATE is equal
to 1.
Syntax
TRE{START}{:Postcond}
Definition
Postcond Any post-conditional expression.
The TRESTART command is executed if the Postcond expression is true or if it is
not supplied on the command. If it is supplied and it is false, execution moves to the
next command after the TRESTART command.
The TRESTART command indicates to the system that the current transaction should
be restarted. If $TLEVEL is greater than 0 and the transaction is marked as
restartable (the TSTART command at $TLEVEL=1 indicates that it is restartable),
TRESTART performs a restart. As part of the restart, local variables specified on the
TSTART command (the TSTART issued with $TLEVEL=1) are restored to their
original value; the program stack is restored to its original location; the naked
indicator is restored; $TEST is restored; and any database updates performed by the
job are rolled back. If $TLEVEL is 0, TRESTART generates an error.
Considerations
In MSM Version 4.3, the commands and special variables associated with the M
Development Committee (MDC) Type A Standard for transactions are only partially
supported; however, the syntax is fully supported.
In addition, if the after-image journal is applied to the database (rolling forward a
bulletproof database after a system failure or applying the journal after a database
restore) the system attempts to apply only complete transactions (SETs and KILLs
bracketed by TSTART and TCOMMIT). A future release of MSM will fully support
transaction processing.
Associated Topics
TCOMMIT Command
TROLLBACK Command
TSTART Command
$TLEVEL Special Variable
$TRESTART Special Variable
Examples
Command Explanation
TRESTART This routine indicates to the system that the current
transaction should be restarted.
TRE:ABORT=1 This routine restarts the current transaction if and only if
ABORT is equal to 1.
Syntax
TRO{LLBACK}{:Postcond}
Definition
Postcond Any post-conditional expression.
The TROLLBACK command is executed if the Postcond expression is true or if it is
not supplied on the command. If it is supplied and it is false, execution moves to the
next command after the TROLLBACK command.
The TROLLBACK command indicates to the system that the current transaction was
not successful. This means that any database changes initiated within the transaction
are not reflected in the database. If $TLEVEL is greater than 0, TROLLBACK
causes a rollback on the SETs and KILLs in the transaction; sets $TRESTART and
$TLEVEL to 0; and causes the naked indicator to become undefined. If $TLEVEL is
0, TROLLBACK generates an error.
Considerations
In MSM Version 4.3, the commands and special variables associated with the M
Development Committee (MDC) Type A Standard for transactions are only partially
supported; however, the syntax is fully supported.
In addition, if the after-image journal is applied to the database (rolling forward a
bulletproof database after a system failure or applying the journal after a database
restore) the system attempts to apply only complete transactions (SETs and KILLs
bracketed by TSTART and TCOMMIT). A future release of MSM will fully support
transaction processing.
Associated Topics
TCOMMIT Command
TRESTART Command
TROLLBACK Command
TSTART Command
$TLEVEL Special Variable
$TRESTART Special Variable
Examples
Command Explanation
TROLLBACK This routine indicates to the system that the current transaction
should be rolled back.
TRO:ROLLBK=1 This routine rolls back the current transaction if and only if
ROLLBK is equal to 1.
Syntax
TS{TART}{:Postcond}SPRestartVar{:TransParm}
Definition
Postcond Any post-conditional expression.
RestartVar One or more local variable names separated by commas and
enclosed in parentheses or asterisk (*).
TransParm One or more keywords or expressions separated by colons and
enclosed in parentheses. When a single keyword or expression
is specified, the parentheses can be omitted.
The TSTART command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the TSTART command.
The RestartVar parameter is used to specify one or more unsubscripted local
variables that are to be saved at the start of the transaction. The names of the local
variables to be saved are separated by commas and enclosed in parentheses. In place
of the local variable names, an asterisk can be specified to indicate that all of the
local variables are to be saved. When a single local variable name is specified, the
parentheses can be omitted. For a transaction to be restartable, one or more local
variables must be specified.
The TransParm parameter is used to specify information about the transaction. The
user can specify SERIAL (abbreviated S) to indicate that the transaction is to be
serialized relative to other transactions. The user also can specify
TRANSACTIONID=Expression (abbreviated T=Expression) to identify arbitrary
classes of transactions.
The TSTART command indicates to the system the beginning of a transaction or
subtransaction. The TSTART command adds 1 to the current value of the $TLEVEL
special variable. If, as a result, $TLEVEL is equal to 1, TSTART initiates a
transaction that is restartable if a RestartVar has been specified. Otherwise, TSTART
initiates a transaction that is not restartable. The transaction that is started is
serializable independently of LOCKs if the SERIAL parameter is present. Otherwise,
it is dependent upon LOCKs for serialization.
When a TSTART command is performed, the system places key information about
the transaction on the system stack. This includes the values of $TEST and the naked
indicator, the execution location of the TSTART command, a copy of the job's
LOCK list, and the appropriate names and values of local variables specified by the
RestartVar parameter.
Considerations
In MSM Version 4.3, the commands and special variables associated with the M
Development Committee (MDC) Type A Standard for transactions are only partially
supported; however, the syntax is fully supported.
Associated Topics
LOCK Command
TCOMMIT Command
TRESTART Command
TROLLBACK Command
TSTART Command
$TLEVEL Special Variable
$TRESTART Special Variable
Examples
Command Explanation
TSTART This routine indicates to the system the start of a transaction.
TS:$TLEVEL=0 This routine starts a transaction if and only if $TLEVEL is equal
to 0.
TS *:S This routine starts a serializable transaction after saving all of the
local variables for the job.
TS (A,B,C):T=2 This routine starts a transaction with an ID of 2 after saving local
variables A, B, and C.
Syntax
U{SE}{:Postcond}SPDevice{:Parm{:Domain}}
Definition
Postcond Any post-conditional expression.
Device An integer expression that indicates which device is to be used.
Parm One or more expressions separated by colons and enclosed in
parentheses that have meaning specific to the device being used.
Domain The name of the mnemonic namespace to be used with the device.
The USE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the USE command.
The USE command makes the specified device the current device. Unless the
specified device is the principal device, ownership of the device must have been
obtained previously with the OPEN command. All input/output operations are always
performed using the current device.
When a CLOSE command is executed for the current device, the system
automatically makes the principal device the current device. No attempt is made to
OPEN the principal device. If an error condition occurs and the $ZTRAP special
variable has not been set to trap the error, the system makes the principal device the
current device before issuing the error message.
The device specified on the USE command can be any valid MSM device. The Parm
specified for the device is specific to the device type. When arguments are listed, the
last argument in the list becomes the current device.
The MSM system maintains device-specific information separately for each device.
This includes the $DEVICE, $KEY, $X, $Y, $ZA , $ZB, and $ZC special variables,
as well as options specified through the Parm specified for a device.
Associated Topics
OPEN Command
CLOSE Command
$DEVICE Special Variable
$KEY Special Variable
$X and $Y Special Variables
$ZA, $ZB, and $ZC Special Variables
Using Peripheral Devices, MSM User's Guide
Command Explanation
USE 4 Device 4 is specified for routing of READ and WRITE data.
U 4 SET X=$IO X receives the value 4.
U 3:132 Device 3 has the right margin set to 132 and is the current
device.
U:X'=0 X The USE command may include a post-conditional expression.
This example inhibits making device 0 the current device.
U 64::"X3.64- Device 64 is assigned the ANSI X3.64-1979 mnemonic
1979"
namespace.
U @X Argument indirection is permitted.
Syntax
V{IEW}{:Postcond}SP{-}Block{:VolGroup}
V{IEW}{:Postcond}SPViewParm where ViewParm is of the form:
Address:{Domain}:Expression{:{ Length}{:Type}}
Definition
Postcond Any post-conditional expression.
Block An expression that identifies a disk block.
VolGroup A string value identifying a volume group.
Address An integer expression.
Domain An integer expression that indicates the area of memory to
modify.
Expression An expression that is to be assigned to the memory area.
Length An integer expression that specifies the length of the area in
memory to modify.
Type Indicates the data type of Expression.
The VIEW command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the VIEW command.
The VIEW command is used to modify the contents of memory and to read or write
disk blocks in the MSM database. In the first form, it is used to access the MSM
database.
The VolGroup specifies the name of the volume group, and the block number
specifies the relative block within the volume group. The VolGroup is specified using
the letter G followed by the volume group number from 0 through 31 (for example,
G0, G1, etc.).
The first block of a volume group is 0, the second block is 1, and so on. If the block
number is non-negative, the specified block is read into the VIEW buffer. If it is
negative, the specified block is written from the VIEW buffer to the database. When
this form of the VIEW command is used, the VIEW device (device 63) must be
owned.
In the second form, the VIEW command is used to modify the contents of system
memory. The user specifies a relative address within memory, the type of memory,
the replacement value, the length of memory to be replaced, and the replacement
type. It is not necessary to own the VIEW device to patch memory unless the area
being patched is within the VIEW buffer.
Associated Topics
$VIEW Function
Using Peripheral Devices, MSM User's Guide
Examples
Command Explanation
VIEW 20 Read block 20 from the MSM database.
V 1:0:255:1 Replace the second location in the VIEW buffer with 255.
V-20 Write the VIEW buffer to the MSM database at block
number 20.
V 120:0:"TEST":4:1 Move the character string TEST into location 120 of the
VIEW buffer.
V 5:"G1" Read block 5 from volume group index number 1.
Syntax
W{RITE}{:Postcond}SPFormat
W{RITE}{:Postcond}SPExpression
W{RITE}{:Postcond}SP*Integer
Definition
Postcond Any post-conditional expression.
Format One or more format or mnemonic controls.
Expression Any valid expression.
*Integer Any valid integer expression.
The WRITE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the WRITE.
The WRITE command is used to output data to the current device. Arguments can be
listed on the WRITE command, and argument types can be intermixed in a single
command. If the current device does not allow output operations, an error occurs.
Format
The WRITE Format form is used to send control commands or mnemonic
namespace sequences to a device. One or more formatting characters can be specified
in each argument. The values of $X and $Y are adjusted accordingly.
Expression
The WRITE Expression form causes the value of the Expression to be written to the
output device, one character at a time, in left-to-right order. The effect of each
character sent to the device is defined by the ASCII Standard and conventions. The
values of the $X and $Y special variables are updated accordingly.
*Integer
The WRITE *Integer form is a one-character write operation that sends the ASCII
character whose decimal code is equal to the integer expression specified as the
argument. The expression is evaluated as modulo 256. This form allows the
programmer to send device-specific sequences to the current device (for example,
Escape sequences or ring the bell). Depending on the device type of the current
device, the value of Integer may be interpreted as a device control command rather
than a single character.
Examples
Command Explanation
WRITE X This routine writes the contents of local
variable X to the current device.
W !,"Line Feed",#,"Form Feed", The arguments used on the WRITE
?20,"TAB",A(3)
command may be mixed.
W *7,*7,*97 This command rings the bell twice, and then
outputs the character a to the current device.
W X,*Y,*Z,!!,"TEST",A=B Expressions containing operators may be
used as arguments.
W:X>10 $J(X,7,2) The WRITE command may be post-
conditionalized. The $JUSTIFY function is
frequently used in the WRITE command.
W /CUP(10,20),X This routine positions the cursor using a
mnemonic namespace sequence and then
writes the value of X.
W @X Indirection may be used in arguments of
W Z,@X,Y
WRITE.
Syntax
X{ECUTE}{:Postcond}SP{Expression}{:Postcond}{,...}
Definition
Postcond Any post-conditional expression.
Expression Any valid expression.
The XECUTE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the XECUTE command. For Postcond expressions on the argument
of the XECUTE command, the argument is skipped if the expression is false.
The XECUTE command is used to execute a line of M code that has been specified
as an argument to the command. Each argument of the command must evaluate to a
string, and the string must be a line of M code in the format returned by the $TEXT
function. In this form, it does not contain a leading TAB character, and it does not end
with a RET character. In addition, it must not contain a label at the beginning of the
string. When execution of the argument terminates, it returns to process the next
argument of the command or the next command following the XECUTE command.
Considerations
The XECUTE command can be thought of as a DO of a one-line subroutine. When
the one-line subroutine is complete, an implicit QUIT is performed by the system.
Associated Topics
DO Command
GOTO Command
QUIT Command
Command Explanation
XECUTE A If A has the value "S X=1", then X receives the
value 1.
X "S X=B Q:X<3 W Y" W "OUT" In this example, the QUIT in the value of the
argument may terminate the execution of the
subroutine. The "OUT" is always written.
X "G A" W "OUT" The string "OUT" is written when A issues a QUIT
command.
X A,B_" D 3 G "_C,D XECUTE may have multiple arguments. Note also
the use of concatenation for stringing together
commands and arguments.
X:Y=1 A_" X B,C",Z XECUTE may contain a post-conditional
expression. Note the nesting of XECUTEs.
X A_" X B,C",Z:Y=1 XECUTE may contain a post-conditional expression
in the argument of the XECUTE.
X @Y,"I @A G "_@D This routine provides an example with indirection at
two levels.
Syntax
ZA{LLOCATE}{:Postcond}
ZA{LLOCATE}{:Postcond}SPVariable{:TimeOut}
ZA{LLOCATE}{:Postcond}SP(Variable{,...}){:TimeOut}
Definition
Postcond Any post-conditional expression.
Variable Any local or global variable name.
TimeOut A timeout value.
The ZALLOCATE command is executed if the Postcond expression is true or if it is
not supplied on the command. If it is supplied and it is false, execution moves to the
next command after the ZALLOCATE command.
The ZALLOCATE command is used to lock both local and global variables. The
MSM system maintains a table of all locked variables (the LOCK table). When a user
attempts to ZALLOCATE a variable, the table is searched to see if it is already
locked by another user. If so, the LOCK request is not granted.
When a lock is requested for a local variable, the lock is known throughout the
system and no other system user can lock the variable. When the lock is for a global
variable, the lock is known only within the UCI and only users running in the same
UCI are prevented from locking the variable.
When a variable is ZDEALLOCATEd, its name is removed from the LOCK table.
Other users then can lock the variable. ZALLOCATE is only a convention. Rather
than preventing users from accessing the locked variable, ZALLOCATE only
prevents them from issuing a LOCK or ZALLOCATE command for the same
variable. In fact, there is no requirement that the locked variable actually exist. The
goal is to have all users follow the same conventions so that simultaneous updates
can be prevented.
Unlike the simple form of the LOCK command, the ZALLOCATE command does
not automatically unlock previously locked variables before trying to lock the
variables specified in the argument. Because the ZALLOCATE command has a
cumulative effect, listing variable names on the command is equivalent to separating
the names with commas and enclosing them in parentheses.
The specified variable name must be a full reference. A naked reference is not
permitted. If the variable name is unsubscripted, the entire variable (including all
descendants) is locked. If a subscripted variable is used, the specified node and all
descendants of the node are locked. In addition, all ancestors of the node are made
unavailable for locking. The naked indicator is not updated for global references in
the LOCK or ZALLOCATE argument.
Compatibility Note
The ZALLOCATE command has been retained for compatibility with older releases
of the MSM system. This command should no longer be used. Instead, the
incremental locking and unlocking capabilities of the LOCK command should be
used.
Considerations
When multiple ZALLOCATE commands are issued for the same variable, it is
LOCKed multiple times. Multiple ZDEALLOCATE commands are required to
remove it from the LOCK list.
Associated Topics
LOCK Command
ZDEALLOCATE Command
Examples
Command Explanation
ZALLOCATE ^TST Between the time execution is resumed after this ZALLOCATE
and the time of execution of a ZDEALLOCATE containing
^TST by this process, no other process is able to execute an
argument of LOCK or ZALLOCATE containing the
unsubscripted global name ^TST or any subscripted global name
whose name part is TST. In addition, any variable previously
LOCKed or ZALLOCATEd by the process remain LOCKed or
ZALLOCATEd.
ZA ^P(1,2),^Q(3) Between the time execution is resumed after the ZALLOCATE,
and the time of execution of a ZDEALLOCATE with an
argument of either ^P(1,2) or ^Q(3) by this process, no other
process is able to LOCK or ZALLOCATE any of the following:
^P ^P(1,2) ^P(1,2,3)
^Q ^Q(3) ^Q(3,4,5)
^P(1)
Syntax
ZD{EALLOCATE}{:Postcond}
ZD{EALLOCATE}{:Postcond}SPVariable
ZD{EALLOCATE}{:Postcond}SP(Variable{,...})
Definition
Postcond Any post-conditional expression.
Variable Any local or global variable name.
The ZDEALLOCATE command is used to unlock one or more variables that were
locked using the ZALLOCATE command. In the argumentless form, all variables for
the current job that were locked with the ZALLOCATE command are unlocked. In
the form with arguments, only the variables specifically named as arguments are
unlocked. Locked variables not specified in the arguments remain locked.
The ZDEALLOCATE command does not operate on variables that were locked
using the LOCK command. It can only be used for variables locked with the
ZALLOCATE command.
Compatibility Note
The ZDEALLOCATE command has been retained for compatibility with older
releases of MSM. This command should no longer be used. The incremental locking
and unlocking capabilities of the LOCK command should be used instead.
Associated Topics
LOCK Command
ZALLOCATE Command
Examples
Command Explanation
ZALLOCATE (^A,^B,^C) Removes ^A from the list of variables LOCKed by the
ZDEALLOCATE ^A
process. The variables ^B and ^C remain LOCKed by the
process.
ZA (^A,^B,^C) Removes ^A and ^B from the list of variables LOCKed by
ZD (^A,^B)
ZA (^D,^E)
the process and adds ^D and ^E to the list.
Syntax
ZF{LUSH}{:Postcond}
Definition
Postcond Any post-conditional expression.
The ZFLUSH command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZFLUSH command.
The ZFLUSH command is used to flush all disk blocks out of the internal disk buffer
cache. All modified buffers are rewritten to the database and then deleted from the
cache. Unmodified buffers are deleted from the cache without being written to disk.
Any subsequent references to routines or globals require the system to reread the
routine or global disk blocks from disk rather than use the values in memory.
Associated Topics
Buffer Pool
Examples
Command Explanation
ZFLUSH This routine flushes all buffers from the cache.
ZF:X=1 This routine flushes all buffers from the cache if X=1.
Syntax
ZG{O}{:Postcond}
Definition
Postcond Any post-conditional expression.
The ZGO command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZGO command.
The ZGO command is used to resume execution of a routine that was suspended by a
BREAK command. A BREAK command suspends execution of a routine only when
the interactive debugger was used to invoke the routine. While the routine is
suspended, the user can enter any M commands or interactive debugger commands.
By entering a question mark (?), a list of valid debugger commands can be displayed.
Changes made to the routine while it is suspended prevent the ZGO command from
restarting the suspended routine.
Associated Topics
BREAK Command
Interactive Debugger
Examples
Command Explanation
S X=^A(3) I X=0 B K ^A When this statement is executed, the routine is suspended.
This allows the programmer to examine the job's status
before the KILL.
ZGO Routine execution continues with the statement that caused
the program to be suspended.
ZG:^A(0)=1 Execution of the routine proceeds only if ^A(0)=1.
Syntax
ZHOROLOG{:Postcond}SP{{±}Date}:{±}Time}}
Definition
Postcond Any post-conditional expression.
Date A date value in $HOROLOG format.
Time A time value in $HOROLOG format.
The ZHOROLOG command is executed if the Postcond expression is true or if it is
not supplied on the command. If it is supplied and it is false, execution moves to the
next command after the ZHOROLOG command.
The ZHOROLOG command is used to temporarily adjust the date, time, or date and
time that are returned by the $HOROLOG function. When the Date operand is
specified and is preceded by a plus sign (+) or minus sign (-), the value is added to or
subtracted from the date portion of the actual system $HOROLOG. Otherwise, the
actual value specified by the Date operand is returned by the $HOROLOG function.
Similarly, when the Time operand is specified and is preceded by a plus (+) or minus
(-) sign, the value is added to or subtracted from the time portion of the actual system
$HOROLOG. Otherwise, the actual value specified by the Time operand is returned
by the $HOROLOG function.
If either operand is omitted, the $HOROLOG function returns the actual system date
or time as appropriate. If no operands are specified, $HOROLOG is reset to the
actual system date and time. The ZHOROLOG command affects the value of the
$HOROLOG special variable only for the partition that issued the ZHOROLOG
command. Other partitions get the unadjusted actual system $HOROLOG value. This
command cannot be abbreviated.
Associated Topics
$HOROLOG Special Variable
Command Explanation
ZHOROLOG:X=1 -10 The ZHOROLOG command sets the date back 10 days
only if X=1.
ZHOROLOG -1:-3600 The ZHOROLOG command sets the date to yesterday
and the time to one hour earlier.
ZHOROLOG @X Indirection may be used with the ZHOROLOG
command.
Syntax
ZI{NSERT}{:Postcond}SPExpression{:LineRef}
Definition
Postcond Any post-conditional expression.
Expression An expression that evaluates to the text of the line to be
inserted.
LineRef A line reference indicating the insert point.
The ZINSERT command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZINSERT command.
The ZINSERT command is used to insert a line of code into the routine that is
currently loaded into the partition. The Expression argument denotes the line of text
to be inserted. It must evaluate to a string that is in the proper format to be inserted
into the routine. The format of the string must be one of the following.
labelSPcommand line
labelTABcommand line
SPcommand line
TAB command line
This is the same format returned by the $TEXT function. The LineRef argument
specifies the location within the routine where the text is to be inserted. The LineRef
expression must evaluate to a line label (for example, ABC), a line label plus an
offset (for example, ABC+3), or simply an offset (for example, +3). The text
specified by expression is inserted immediately following the line specified by
LineRef.
If the LineRef argument is omitted, the current implicit line pointer location is used.
The implicit line pointer location is set by the ZPRINT and ZREMOVE commands.
ZINSERT does not alter the implicit line pointer location.
Considerations
The ZINSERT command can be issued only from within an XECUTE command or
from the open command language (the > programmer prompt). To prevent the loss of
issued ZINSERT lines, the routine can be stored permanently in the database by
issuing a ZSAVE command.
Associated Topics
Using the MSM System, MSM User's Guide
$TEXT Function
ZLOAD Command
ZPRINT Command
ZREMOVE Command
ZSAVE Command
Command Explanation
ZINSERT "DEF READ X":ABC This routine inserts a line after the line labeled ABC.
ZI " SET Y=X+4" This routine inserts the line after the current insert
point.
ZI " W !!,X+Y":+4 This routine inserts the line after the fourth line of the
program.
ZI:X=1 Y:+T The ZINSERT command may include a post-
conditional expression.
ZI @X Indirection may be used in the ZINSERT command.
ZI "HDR ;NEW LINE":+0 This routine inserts a line before the first line of the
program.
Syntax
ZL{OAD}
ZL{OAD}{:Postcond}SP{RoutName}
Definition
Postcond Any post-conditional expression.
Routname Any valid routine name.
The ZLOAD command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZLOAD command.
The ZLOAD command is used to load a routine into the partition from the current
device or from the MSM database. In the argumentless form, the routine is loaded
from a device. The device that contains the routine to be loaded must be OPEN, and
it must be the current device. In this form, the input lines are entered in the same
format returned by the $TEXT function, and each line is terminated with the RET
character. End of input is signaled by a null line (a line containing only the RET
character).
In the form with an argument, the specified routine is loaded from the routine
directory in the current UCI. The routine name begins with an alpha character or a
percent sign (%) and is followed by alphanumeric characters. If the name is longer
than eight characters, all characters after the eighth one are ignored. The name is not
preceded by the circumflex (^) character.
Considerations
As the first step in executing a ZLOAD command, an implicit ZREMOVE command
with no arguments is performed. This clears any existing routines from the partition.
addition, because ZLOAD removes the current routine, it can only be used in direct
mode or in an XECUTE command.
Associated Topics
$TEXT Function
$ZNAME Special Variable
ZINSERT Command
ZREMOVE Command
ZSAVE Command
Using the MSM System, MSM User's Guide
Command Explanation
ZLOAD ABC This routine loads routine ABC from the current UCI into the
partition.
ZL This routine loads a routine into the partition from the current
device.
ZL:X=1 XYZ This routine loads routine XYZ into the partition only if X=1.
ZL @X Indirection may be used with the ZLOAD command.
Syntax
ZM{SM}{:Postcond}SPExpression{:Device}
Definition
Postcond Any post-conditional expression.
Expression An integer expression that indicates the type of trace to perform.
Device A device designator indicating the output device for the trace.
The ZMSM command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZMSM command.
The ZMSM command is used to trace the flow of various types of events in MSM to
aid in debugging. The Expression argument is used to indicate the type of function in
MSM that is to be traced. If the value of the Expression is 0, the trace is disabled. If
it is greater than 0, one or more functions within MSM are traced. The following
table lists the events that can be traced.
When trace is enabled, descriptive messages about the events are displayed on the
current device. By specifying the Device argument, these messages can be directed to
some other device. The device must be owned by the job (OPEN); otherwise, an
error occurs.
Associated Topics
Using Peripheral Devices, MSM User's Guide
Examples
Command Explanation
ZMSM 1 This routine enables the trace function to display the execution
path.
ZM 1:3 The trace function is enabled and the output is directed to device
3.
ZM 0 The trace function is disabled.
ZM:X=1 1 The trace function is only be enabled if X=1.
ZM @X Indirection may be used in the ZMSM command.
Syntax
ZN{EW}{:Postcond}SPLocalVar{,...}
Definition
Postcond Any post-conditional expression.
LocalVar An unsubscripted local variable name.
The ZNEW command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZNEW command.
The ZNEW command is used to make temporary copies of unsubscripted local
variables. When a temporary copy is created, the old variable, its value, and the
values of all its descendants are copied onto a stack. When a QUIT command is
encountered, the stacked values are restored (merged) to the local symbol table.
Only the local variables specifically named as arguments of the ZNEW command are
stacked. Local variable names cannot include subscripts. If the name includes
subscripts, an error occurs. Variables are not killed after they are stacked.
Considerations
The ZNEW command only works on local variables, not global variables. In direct
(programmer) mode , the ZNEW command can be used to stack variables; however,
after the command line is executed, an implicit QUIT is performed before returning
to direct mode. This causes the stacked variables to be unstacked. Excessive use of
the ZNEW command in a program can result in an out-of-space condition within the
partition (STORAGE=0).
The ZNEW command differs from the NEW command in that the variable being
stacked is not KILLed after the ZNEW command.
Associated Topics
KILL Command
MERGE Command
NEW Command
QUIT Command
$STORAGE Special Variable
Command Explanation
ZNEW X This routine stacks local variable X.
ZNEW A,B This routine stacks A and B and their descendants. On a QUIT,
the system unstacks the hidden A and B variables, in effect
merging them with the current copy of A and B.
ZN:X=1 X This routine stacks local variable X and all of its descendants if
and only if X=1.
ZN @X ZN A,@B,C Indirection may be used in the ZNEW command.
Syntax
ZP{RINT}{:Postcond}
ZP{RINT}{:Postcond}SP{StartLine}{:EndLine}
Definition
Postcond Any post-conditional expression.
StartLine A line reference for the starting line.
EndLine A line reference that indicates the ending line.
The ZPRINT command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZPRINT command.
The ZPRINT command is used to output one or more lines of a routine to the current
device. In the argumentless form, the entire routine is written to the current device.
The implicit line pointer that is used for data entry of routine lines is set to the end of
the routine.
In the form with arguments, all lines from and including the StartLine, through and
including the EndLine, are output to the current device. The format of the lines is the
same as returned by the $TEXT function, and each line ends with a carriage
return/line feed sequence.
The StartLine and EndLine expressions can evaluate to a line label (for example,
ABC), a line label plus an offset (for example, ABC+3), or simply an offset (for
example, +3). For simple offsets, the numeric value is the number of lines from the
start of the routine. The first line is +1, the second is +2, and so on.
If only the StartLine is specified, then the single line indicated by the expression is
output to the current device. If the EndLine is specified and it is null, all lines from
and including the StartLine through the end of the routine are output to the current
device. In both forms, the implicit line pointer used for data entry of routine lines is
set to the last line output to the current device.
Associated Topics
$TEXT Function
ZINSERT Command
Command Explanation
ZPRINT ABC This routine writes the line labeled ABC to the current device.
ZP +1:+5 This routine writes the first five lines of the routine to the current
device.
ZP START+1 This routine writes the single line that immediately follows the line
labeled START.
ZP This routine writes the entire routine.
ZP:X=1 +X:+Y This routine only writes out the specified portion of the routine if
X=1.
ZP X: This routine writes out all lines from label X through the end of the
routine.
ZP @A:@B Indirection may be used in the ZPRINT command only if local
variables contain line labels. Note that the indirection must evaluate
to a pure LABEL. LABEL+offset is not supported in this context.
Syntax
ZQ{UIT}{:Postcond}
Definition
Postcond Any post-conditional expression.
The ZQUIT command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZQUIT command.
To understand the operation of the ZQUIT command, it is first necessary to
understand how error trapping is implemented in MSM. When a DO or XECUTE
command is processed, the MSM system creates a new execution level. This is done
so that when a DO or XECUTE command terminates either through an implicit
QUIT (end of routine encountered) or an explicit QUIT, the system can return to the
point at which the command was initiated.
Each execution level created by a DO or XECUTE command is numbered.
Programmer mode is considered to be execution level 1, the first DO or XECUTE
command is level 2, the second is level 3, and so on. The execution level that is
currently in control generally is referred to as the current execution level.
One $ZTRAP special variable can be set at each execution level (level 1, level 2, and
so on). This means that each execution level in an application can establish its own
error trapping routine and error recovery procedures.
When a ZQUIT command is issued from within an error handling routine, it returns
to the next higher execution level that contains an error processing routine. If none
exists, the system returns to the highest execution level (level 1, which generally is
programmer mode).
Alternatively, a GOTO command can be used to transfer control to another program
at the same level, or a QUIT command can be used to return to the command that
follows the DO or XECUTE command at the next higher level.
Refer to the MSM User's Guide for a complete description of error handling and use
of the ZQUIT command.
Associated Topics
DO Command
GOTO Command
QUIT Command
XECUTE Command
$ZERROR Special Variable
$ZTRAP Special Variable
Command Explanation
ZQUIT Exit from the error routine and return to the next higher error processing
routine.
ZQ:X=1 Exit from error routine only if the value of X equals 1.
TEST ;NEW PROGRAM
S $ZT="ERR1" D ONE
Q
ONE S $ZT="ERR2" D ONE
Q
TWO W 1/0
Q
ERR1 W !,"JUMP FROM ZQUIT" Q
ERR2 W !,"ERROR IN LABEL TWO"
ZQ
Syntax
ZR{EMOVE}{:Postcond}
ZR{EMOVE}{:Postcond}SP{StartLine}{:EndLine}
Definition
Postcond Any post-conditional expression.
StartLine A line reference for the starting line.
EndLine A line reference that indicates the ending line.
The ZREMOVE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZREMOVE command.
The ZREMOVE command is used to delete one or more lines of a routine. In the
argumentless form, the entire routine is deleted from the partition and $ZNAME is
set to null. The implicit line pointer that is used for data entry is set to the beginning
of the routine.
In the form with arguments, all lines from and including the StartLine, through and
including the EndLine, are deleted from the partition. The StartLine and EndLine
expressions can evaluate to a line label (for example, ABC), a line label plus an
offset (for example, ABC+3), or simply an offset (for example, +3). For simple
offsets, the numeric value is the number of lines from the start of the routine. The
first line is +1, the second is +2, and so on.
If only the StartLine is specified, then the single line indicated by the expression is
deleted from the current routine. If the EndLine is specified and it is null, an error
occurs. When the EndLine appears in the routine before the StartLine, no action takes
place (no lines are deleted). In the form with arguments, the implicit line pointer used
for data entry of routine lines is set to the line that immediately precedes the first
deleted line.
Note If the partition is empty (no routine is loaded in the partition) and a ZSAVE
command is entered, the named routine is deleted from the routine directory.
Associated Topics
Implicit Line Pointer
ZINSERT Command
ZLOAD Command
ZSAVE Command
$ZNAME Special Variable
Using the MSM System, MSM User's Guide
Command Explanation
ZREMOVE +1 This routine removes the first line of the routine currently loaded
into the partition.
ZR +10:+15 This routine removes the tenth line through the fifteenth line of the
current routine.
ZR A:B This routine removes all lines from label A through label B,
inclusive.
ZR:Z=2 TEST This routine removes the single line labeled TEST only if Z=2.
ZR @A:@B Indirection may be used in the ZREMOVE command. The
indirection must evaluate to a pure LABEL. LABEL+offset is not
supported in this context.
Syntax
ZS{AVE}{:Postcond}
ZS{AVE}{:Postcond}SPRoutName{:{Level}{:Expression}}
Definition
Postcond Any post-conditional expression.
Routname Any valid routine name.
Level An integer expression that indicates the level of source code that
is to be retained with the saved routine.
Expression A numeric expression that prevents a routine from being saved if
the compiler detects errors.
The ZSAVE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZSAVE command.
The ZSAVE command is used to write the routine currently loaded into the partition
to the routine directory in the current UCI. In the argumentless form, a routine name
must already be associated with the routine in the partition. The routine name can be
accessed using the $TEXT function ($TEXT(+1) returns the name) or the $ZNAME
special variable. If no name is associated with the routine and the argumentless form
of ZSAVE is used, a <NOPGM> error occurs.
In the form with arguments, the routine is saved using the name specified by the
Routname argument. After the save, the name associated with the routine is the name
specified as the argument.
The Level argument is used to control how much of the source code is retained with
the routine when it is saved. The argument must evaluate to an integer that has a
value of 0 through 15, inclusive. If this argument is omitted, a value of 0 is assumed.
As part of the ZSAVE process, the MSM system compiles the routine lines to a
pseudo-code format. All or part of the source code can be removed as part of this
process. If $TEXT is used to reference a line whose source code has been removed,
the function returns a single blank. The following table lists the available levels.
The Expression argument is used to control whether or not the system saves the
routine in the event that errors are detected. If the Expression has a value of 0 or is
not present, the routine is saved even if it contains errors. If the Expression has a
value of 1, the routine is not saved if errors are found. The system can detect only
compile-type errors (for example, <SYNTX> error), and not runtime errors (for
example, <UNDEF> error).
When an Expression Value of 1 has been specified, the $ZA special variable is
updated as part of the routine save operation. If the compiler found no errors in the
routine, $ZA contains a value of 0. Otherwise, $ZA contains the number of the line
that contains the error, relative to the beginning of the program. The first line in the
program is considered to be 1, the second is 2, and so on. The number returned in
$ZA can be used as the argument to the $TEXT function to retrieve the line that
contains the error.
When an error is detected, the $ZB special variable contains the relative
displacement in the line in which the error was detected. The first character in the
line is 1, the second is 2, and so on. By using a combination of $ZA and $ZB, the
actual location of the error in the program can be displayed.
After a ZSAVE command with an Expression Value of 1, the values of $ZA and $ZB
remain valid until another M command is processed that updates the values of these
special variables. M commands that update the $ZA and $ZB special variables
include OPEN, USE, READ, JOB, etc. When the ZSAVE is done in programmer
mode, the MSM system implicitly performs a USE $I command before issuing the
command prompt. Therefore, the programmer should save the value of $ZA as part
of the ZSAVE command.
Note If the partition is empty (no routine is loaded in the partition) when a ZSAVE
command is entered, the named routine is deleted from the routine directory.
Considerations
Error conditions can result when changes are made to a routine that is being executed
by a job or is executed by a job as it returns through its execution stack as a result of
QUIT commands. Internally, MSM tries to determine whether the changes impact the
job that is using the routine. If the system determines that the changes will affect the
job, it marks the routine so that the job receives a <CLOBR> error when it tries to
use the changed routine. Otherwise, the job is allowed to use the changed routine
without generating an error. To prevent error conditions, care should be taken when
changing a routine that is in use.
Examples
Command Explanation
ZSAVE TEST ZSAVE saves the routine currently loaded into the
partition on disk under the name TEST.
ZS ZSAVE saves the current routine using the name
contained in the $ZNAME special variable.
ZS MYPROG:1 This routine saves the current routine with name
MYPROG and removes all source code except
comment lines.
ZR ZS INIT This routine deletes the routine named INIT from
the Routine Directory of the current UCI.
ZS:Z=1 ABC The routine is saved only if Z=1.
ZS @X Indirection may be used with the ZSAVE
command.
S Y=X:1 ZS @Y This routine saves X without the text.
ZS YOURPROG::1 S A=$ZA,B=$ZB This routine saves the program if and only if no
errors are detected during the compile. In addition,
saves the value of $ZA and $ZB before the
command prompt is issued.
Syntax
ZSE{TOBJ}{:Postcond}SPVariable=Expression
ZSE{TOBJ}{:Postcond}SP(Variable{,...})=Expression
Definition
Postcond Any post-conditional expression.
Variable Either a local variable name or a property of an object.
Expression Any expression that evaluates to an object reference.
The ZSETOBJ command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZSETOBJ command.
The ZSETOBJ command is used to assign the value of the Expression to one or more
variables or object properties, including the default property. When multiple
Variables are to be assigned the same value, their names are separated by commas
and enclosed in parentheses. Execution of the ZSETOBJ command occurs in the
following order:
Any indirection or subscripts that appear in the argument are evaluated in a left-to-
right order.
The Expression is evaluated according to the specified rules.
The value of the Expression is assigned to each Variable, one at a time in a left-to-
right order if there are several. If the Variable includes subscripts and the specified
node does not exist, the system creates the node and the minimum number of ancestor
nodes required to provide a path to the new node. When the ancestor nodes are
created, they are defined so that they have a descendant but no data value (when the
$DATA function is applied to a created ancestor node, its value is 10).
Associated Topics
Variables
Binary EQUALS Operator
SET Command
Examples
Command Explanation
ZSETOBJ X=Y The value (which must be an object
reference) of the unsubscripted
variable Y is assigned to the
unsubscripted local variable X. The
previous value of X is discarded.
ZSE A(1,2)=Y(1) This works similarly for subscripted
variables.
ZSE A(1)=X,B(4)=D This shows multiple arguments of
ZSETOBJ.
ZSETOBJ:PC>5 (A,B,C)=MYOBJ This is a "multiple" set. All variables in
the parentheses are set to the same
object reference value. Note the use of
the post-conditional. The ZSETOBJ
command is executed only if local
variable PC has a value greater than 5.
SET ^A(1)=0 ZSE (A,B)=MYOBJ,A(3)=W, Multiple and single ZSETOBJs may be
(A(^(3,5),4),B(5))=XXX(^(4))
mixed in one command. When
subscripts occur to the left of the equal
sign, they are evaluated before the
right-side expression. In this example,
the ^(3,5) evaluates to ^A(3,5) due to
the setting of the naked by the "SET
^A(1)." Therefore, ^(4) becomes
^A(3,4). Even in a multiple set, the left
subscripts are evaluated before the
assignment is made, but each argument
is completed before the next is begun.
Syntax
ZSY{NC}{:Postcond}
Definition
Postcond Any post-conditional expression.
The ZSYNC command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZSYNC command.
In MSM, any global SET (update) or KILL operations performed over a network are
buffered by the system to improve efficiency. They can be processed later by the
system to which they are being sent. The ZSYNC command has been implemented to
provide a mechanism for a job to ensure that all global transactions have been
completed by the other system. When the ZSYNC command is issued, the current job
is suspended until all in-progress network transactions are complete.
Considerations
The ZSYNC command can be used with remote volume group (RVG) support or
with Distributed Data Processing (DDP) support. For systems in which RVG or DDP
support are not active, the ZSYNC command is ignored.
Associated Topics
Configuring the System, MSM User's Guide
%DBSYNC and %MODESET Utilities
Examples
Command Explanation
ZSYNCH Flushes the network transactions for the current job.
Syntax
ZT{RAP}{:Postcond}SPString
Definition
Postcond Any post-conditional expression.
String A string expression that specifies the text of the error to be
displayed.
The ZTRAP command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZTRAP command.
The ZTRAP command is used to force an error condition during routine execution.
When the error condition occurs, routine execution is terminated in the same manner
as any other type of error condition. Any error traps set by the routine are honored.
The String argument is an expression that evaluates to a one-to four-character string
that indicates the specified error type. The letter Z followed by the specified string is
displayed as the error code in the standard MSM error message. If the expression is
null or not specified, a default value of TRAP is used.
Associated Topics
QUIT Command
ZQUIT Command
$ZERROR Special Variable
$ZTRAP Special Variable
Appendix B, Error Processing
Examples
Command Explanation
ZTRAP "1234" <Z1234>+17^CUSINQ:::6:17
ZT "err1" <Zerr1>+21^CUSLOG:::6:17
ZT <ZTRAP>+45^CUSMAST:::6:17
ZT "A" <ZA>+12^CUSSRCH:::6:17
ZT @X Indirection can be used in the ZTRAP command.
Syntax
ZU{SE}{:Postcond}SPDevice
Definition
Postcond Any post-conditional expression.
Device Any valid terminal device designator.
The ZUSE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZUSE command.
The ZUSE command is used to temporarily gain ownership of a device that may
already be owned by another job. The primary purpose of ZUSE is to allow messages
to be broadcast to system users. The ZUSE command makes the device specified by
the device argument the current device without using the OPEN and USE commands.
The specified device must be a terminal type device that is currently active on the
system. When a device is acquired through the ZUSE command, only the WRITE
command can be used with the device. Any other input/output command causes an
error.
Associated Topics
USE Command
WRITE Command
Using Peripheral Devices, MSM User's Guide
Examples
Command Explanation
ZUSE 4 W !,"SYSTEM AVAILABLE UNTIL This routine sends a broadcast message
23:00 TONIGHT"
to a specific terminal device.
ZU:X=1 64 The ZUSE command obtains the device
only if X=1.
ZU @X Indirection can be used with the ZUSE
command.
Syntax
ZW{RITE}{:Postcond}
ZW{RITE}{:Postcond}SPVariable{,...}
Definition
Postcond Any post-conditional expression.
Variable Any subscripted or unsubscripted local variable name.
The ZWRITE command is executed if the Postcond expression is true or if it is not
supplied on the command. If it is supplied and it is false, execution moves to the next
command after the ZWRITE command.
The ZWRITE command is used to display the values of one or more local variables
and their descendants on the current device. Variables are displayed in ASCII
collating sequence.
In the argumentless form, all local variables are displayed. In the form with
arguments, only the specified local variables are displayed. If the specified local
variable has descendants, all descendants also are displayed.
Associated Topics
Variables
Examples
Command Explanation
ZWRITE ZWRITE writes the contents of the local symbol table to the
X=0 current device.
Y="23"
CODE=""
CODE(1)="R499"
CODE(2)="MM88"
CODE(3)="A1AA"
ZW CODE This routine writes the value of the variable CODE and all
CODE= of its descendants.
CODE(1)="R499"
CODE(2)="MM88"
CODE(3)="A1AA"
S X=10 Indirection may be used with the ZWRITE command, but
S Y="X"
ZW @Y
the indirection must yield a local variable that was
previously defined.
1.
Overview
This chapter describes the ANSI-standard M functions and the additional functions
that are provided in the MSM implementation of M. It also explains how users can
write their own functions.
In the MSM system, a function is an operation that returns a single numeric or string
value. The ANSI-standard definition for the M language defines the following two
function types.
Intrinsic A built-in function defined by the system (for example, $DATA or
$PIECE).
Extrinsic A user-defined function that has been implemented as an M routine.
The following sections describe both function types and how the M programmer can
use them.
Intrinsic Functions
The M language contains functions that the programmer can use to facilitate creation
of programs or routines, as they are referred to in MSM. Functions supplied with the
system as part of the M language are referred to as intrinsic functions. An intrinsic
function is a directive to the compiler to perform a specific action and then return a
single value that results from the action. Each function performs a specific action that
is further defined by the arguments associated with it.
An intrinsic function is represented by a dollar sign ($), followed by the function
name, followed by one or more parameters enclosed in parentheses.
The following illustrates the syntax of an intrinsic function.
$FuncName(ActualList)
FuncName Any MSM-supplied function name.
ActualList One or more arguments (expressions) separated by commas.
Extrinsic Functions
An extrinsic function is always a user-defined function that was written in M. It uses
the parameter-passing mechanism of MSM to receive arguments and return values.
An extrinsic function can be used anywhere in MSM where an expression is allowed.
An extrinsic function is identified by two dollar signs ($$), followed by the function
name (an EntryRef that identifies the M routine which performs the desired action),
followed by zero or more parameters enclosed in parentheses. The syntax of an
extrinsic function is as follows.
$$EntryRef(ActualList)
EntryRef A reference which identifies the M routine that performs a specific
function.
ActualList An argument list that specifies the actual list of parameters to be
passed to the function. It consists of zero or more arguments
separated by commas.
Examples
Consider the following routine:
VOL(R,H) ; Calculate volume of a cylinder
; R=radius, H=height
; V= pi * (radius squared) * height
Q 3.14159265*R*R*H
the variable VOLUME equals the volume of a cylinder of radius "RAD" and height "H." This
is an example of call-by-value parameter passing.
the number 256 is written to the current device. If the code is rewritten as follows:
SET X=2,Y=8 W $$^%EXP(.X,Y)
the output is the same, but the value of variable X is changed to 256. This is an example of
call-by-reference parameter passing.
Consider the following routine:
%FMRD(H) ; Convert $H date to FileMan date
S X=$ZDATE(H)
EXIT ;
Q 2_$P(X,"/",3)_$P(X,"/")_$P(X,"/",2)
T() ; Return FileMan date for today
S X=$ZD($H) G EXIT
When the following is executed:
SET FMRDAT=$$^%FMRD($H-10)
the variable FMRDAT contains the FileMan internal date for ten days before execution of the
program. If the following code is executed:
S TODAY=$$T^%FMRD
the variable TODAY is set to the current FileMan date. In this case, $$T^%FMRD is called an
extrinsic variable, because parameters are not passed to the subroutine. Note that label "T"
must have at least a null formal list even when it is used as an extrinsic variable.
Syntax
$A{SCII}(String{,Position})
Definition
String Any string-type expression.
Position An integer expression that indicates the relative position of a
character within the String.
The $ASCII function returns an integer value that is the decimal equivalent of the
ASCII code of the specified character. The decimal value is translated from the
ASCII code in the String at the location specified by the Position argument. If
Position is omitted, a value of 1 is assumed. The function returns a value of -1 if the
String is null or if the location specified by Position is less than 1 or greater than the
length of the String.
If an alternative character set (such as a double-byte character set) is in effect,
$ASCII returns the value of the character in that character set.
Associated Topics
$CHAR Function
ASCII Character Set
Examples
Syntax
$C{HAR}(Decimal{,...})
Definition
Decimal An integer expression that is the decimal value of the desired
ASCII character.
The $CHAR function returns a string of ASCII characters whose length is equal to
the number of non-negative Decimal arguments supplied to the function. If the
Decimal value is less than 0, it translates to a null value. If it is greater than 255, an
error occurs unless a double-byte or wide character set is being used.
If an alternative character set (such as a double-byte character set) is in effect,
$CHAR interprets the integers as character codes in that character set and returns
characters of that character set.
Associated Topics
$ASCII Function
ASCII Character Set
Examples
Syntax
$D{ATA}(Variable)
Definition
Variable An expression that evaluates to a local or global variable name.
The $DATA function returns a value that indicates whether the global or local
variable specified by Variable is defined, has data, and has descendants. The
following values are returned by the function.
0 The global or local variable is not defined, has no data, and has no
descendants.
1 The global or local variable is defined, has data, but has no descendants.
10 The global or local variable is defined, has no data, and has descendants.
11 The global or local variable is defined, has data, and has descendants.
If the variable is specified using a naked reference, the naked indicator must have
been previously set.
Examples
Syntax
$E{XTRACT}(String{,Begin{,End}})
Definition
String A string-type expression.
Begin An integer expression that specifies the starting location of the
substring within the String.
End An integer expression that specifies the ending location of the
substring within the String.
The $EXTRACT function returns a substring from the specified String starting at
location Begin and ending at location End. When no Begin location is specified, a
value of 1 is assumed. If no End location is specified, it is assumed to be the same as
the starting location.
The function returns a null value under the following conditions: when the Begin
value is greater than the length of the String; when the End value is less than 1; when
the Begin value is greater than the End value; or when the End value is not specified
and the Begin value is less than 1.
The $EXTRACT function can appear on either side of the equal sign (=) in the
argument of the SET command. When it appears on the right side of the equal sign, it
returns the specified substring. When it appears on the left side of the equal sign, the
specified substring is replaced by the value to the right of the equal sign.
When SET $EXTRACT notation is used, the String being set must be a pure local or
global variable name. Other expression types are not allowed. If the variable being
SET is not long enough (Begin and/or End are beyond the length of the variable), the
variable is padded with blanks, as needed. If the variable being SET does not exist, it
is treated as if it was equal to the null string.
Syntax
$F{IND}(String,Substring,{Begin})
Definition
String Any string-type expression.
Substring Any string-type expression that is to be located within String.
Begin An integer expression that indicates the location where the
search is to start.
The $FIND function searches a String to see if it contains a specified Substring. If it
does, then the function returns an integer value that is the location of the character
immediately to the right of the Substring's last character. The function returns 0 if the
Substring is not contained in the String.
Although the search generally begins with the first character of the String, the Begin
argument can be used to specify a different starting location. If the starting location is
less than 1, a value of 1 is assumed. When the Substring occurs more than once in the
String, the function returns the location of the first occurrence found after the starting
location. When the specified Substring is null, the function returns the starting
location.
Associated Topics
$LENGTH Function
CONTAINS Operators
Syntax
$FN{UMBER}(Number,Format{,Fraction})
Definition
Number Any numeric type expression.
Format A string expression that specifies the formatting to be performed on
the Number.
Fraction An integer expression that specifies the number of digits to the
right of the decimal point to display.
The $FNUMBER function returns the specified Number as a string, formatted
according to a pattern specified by the Format codes. The Format codes are defined
in the following table.
The order in which the Format codes are specified does not affect the processing. If a
particular Format code is specified more than once, it is ignored. When the specified
Format is null, the original value of Number is returned. An error condition results if
the Format code "P" is specified along with "T," "+," or "-" in the string.
If Fraction is specified, it indicates the number of places to the right of the decimal
point to display. When the Number is evaluated, the specified number of decimal
places is calculated, with padding, truncation, or rounding, if appropriate. Trailing
zeros are added, if needed to display the proper number of fraction places. If
-1 < Number < 1, a leading 0 is added to the left of the decimal point.
Syntax
$G{ET}(Variable{,DefaultVal})
Definition
Variable An expression that evaluates to a local or global variable name.
DefaultVal An expression that specifies the data to be returned if the Variable
is not defined.
The $GET function returns the data value of the Variable, if it exists
($DATA(Variable)=1 or 11). If it does not exist, the function returns the value
specified by DefaultVal. If no DefaultVal is specified, a value of null is assumed. If a
DefaultVal is specified, it is always evaluated by the function. This ensures that the
state of the naked indicator always is predictable.
Associated Topics
Variables
$DATA Function
Examples
Syntax
$J{USTIFY}(String,Field{,Fraction})
Definition
String Any string-type expression.
Field An integer expression that specifies the size of the string to be
returned.
Fraction An integer expression that specifies the number of digits to the right
of the decimal point to display.
The $JUSTIFY function returns the String right-justified in a string of blanks whose
length is specified by Field. If the length of the String is greater than or equal to
Field, the function returns the String. Otherwise, it returns the String with as many
blank characters concatenated to the front as necessary to yield the length specified
by Field. If Fraction is specified, it indicates the number of places to the right of the
decimal point to display. When the String is evaluated, the specified number of
decimal places is calculated, with rounding if appropriate. The length specified by
Field includes the sign character (if present) and the decimal point (if present).
Examples
Syntax
$L{ENGTH}(String{,Substring})
Definition
String Any string-type expression.
Substring Any string-type expression that is to be counted within String.
The $LENGTH function returns an integer value that indicates the number of
characters in String. If String is null, the function returns 0. If a substring is specified,
the function returns an integer value that is one greater than the number of
non-overlapping times the Substring is contained in the String. If the Substring is
specified and it is null, the function returns 0.
Examples
Syntax
$NA{ME}(Variable{,Subscripts})
Definition
Variable An expression that evaluates to a local or global variable name.
Subscripts An expression that specifies the number of subscripts to be
returned in the Variable name.
The $NAME function returns a string value that is a full local or global reference
denoting all or part of the specified Variable. If the Subscript argument is not
specified or is 0, the value returned is the Variable name. Otherwise, the function
returns a full local or global reference that contains up to the specified number of
subscripts.
Considerations
When naked references are used within the $NAME function, a string corresponding
to the full reference is returned. However, the $NAME function does not affect the
naked indicator.
Associated Topics
Variables
Naked References
Examples
Syntax
$N{EXT}(Variable{,Direction})
Definition
Variable An expression that evaluates to a subscripted local or global variable
name.
Direction An expression that evaluates to either 1 or -1.
The $NEXT function is used to identify the next or previous subscript in sequence at
a given level. The Variable name that is specified as an argument to the function may
be subscripted, and naked references are allowed. If Direction is not specified or has
a value of 1, then for the right-most subscript in the Variable, the system returns the
next subscript value that follows it. If no subscript follows it, the function returns -1.
If the right-most subscript in the reference is -1, the system returns the value of the
first subscript or the last subscript at that level, depending on the value of Direction.
If Direction is specified and evaluates to -1, the function returns the previous
subscript for the variable. If Direction is specified and has any value other than 1 or
-1, an error condition occurs.
The $NEXT function returns the subscripts in the collating sequence defined for the
global (string or numeric sequence). For local variables, the subscripts are always
returned in numeric order. The $NEXT function has been retained to provide
compatibility with applications developed on earlier M implementations. Although
the $ORDER function performs the same function as $NEXT, it supports string
subscripts and negative numeric subscripts. Therefore, the $ORDER function is the
preferred choice.
$NEXT can be used to step through the local symbol table. If Variable evaluates to
an unsubscripted local variable, $NEXT either returns the next or previous variable
defined in the partition, or -1 if none exists. Because $NEXT has no starting point
when it is used in this manner, one must start with $NEXT(), which returns the name
of the first or last variable in the partition.
Associated Topics
$ORDER Function
$QUERY Function
$ZNEXT Function
$ZORDER Function
$ZPREVIOUS Function
$ZSORT Function
Examples
Syntax
$O{RDER}(Variable{,Direction})
Definition
Variable An expression that evaluates to a local or global variable name.
Direction An expression that evaluates to either 1 or -1.
The $ORDER function is used to identify the next or previous subscript in sequence
at a given level. The Variable name that is specified as an argument to the function
must be subscripted, and naked references are allowed. If Direction is not specified
or has a value of 1, then for the right-most subscript in the Variable, the system
returns the next subscript value that follows it. If no subscript follows it, the function
returns a null value. If the right-most subscript in the reference is a null value, the
system returns the value of the first or last subscript at that level, depending on the
value of Direction. If Direction is specified and evaluates to -1, the function returns
the previous subscript for the variable. If Direction is specified and has any value
other than 1 or -1, an error condition occurs.
The $ORDER function returns the subscripts in the collating sequence that was
defined for the global (string or numeric sequence). For local variables, the subscripts
always are returned in numeric order. The $ZSORT function is identical to the
$ORDER function, except that for local variables, it returns the subscripts in
string-collating sequence.
$ORDER can be used to step through the local symbol table. If Variable evaluates to
an unsubscripted local variable, $ORDER either returns the next local variable
defined in the partition or null if none exists. Because $ORDER has no starting point
when used in this manner, one must start with $ORDER() to obtain the name of the
first or last local variable in the partition.
Although the $ORDER function performs the same function as $NEXT, it supports
string subscripts and negative numeric subscripts. The $ORDER function thus is the
preferred choice.
Associated Topics
$NEXT Functions
$QUERY Function
$ZNEXT Function
$ZORDER Function
$ZPREVIOUS Function
$ZSORT Function
Examples
Syntax
$P{IECE}(String,Delimiter{,First{,Last}})
Definition
String Any string-type expression.
Delimiter One or more characters that are delimiters for the substring.
First An integer expression that specifies the starting occurrence of the
substring to retrieve.
Last An integer expression that specifies the ending occurrence of the
substring to retrieve.
The $PIECE function returns one or more substrings that are contained in the String.
The substring may appear none, one, or more non-overlapping times in the String
separated by the Delimiter. The Delimiter may be one or more characters that appear
in the String. Each substring has a unique position relative to the Delimiter in the
String. In the following example, the asterisk (*) character is used as the Delimiter.
ABC*DEF*GHI*JKL
In this case, ABC is the first substring, DEF is the second substring, GHI is the third
substring, and so on. If the Delimiter is not found in the String, the function returns
the entire String. The First argument is used to indicate which substring to retrieve.
When the First argument is not specified, the function returns the first substring.
When the Last argument is specified, all substrings from the First through the Last
are returned. The function returns a null string if the Delimiter is null; the value of
First is greater than the value of Last; the value of Last is less than 1; or there are less
than First -1 non-overlapping occurrences of the Delimiter in the String.
The $PIECE function can appear on either side of the equal sign (=) in the argument
of the SET command. When it appears on the right side of the equal sign, it returns
the specified piece. If it appears on the left side of the equal sign, the specified piece
is replaced by the value to the right of the equal sign. When SET $PIECE notation is
used, the String being set must be a pure variable name. Other expression types are
not allowed.
If the variable being SET does not have enough delimiters to update the appropriate
piece, the $PIECE function pads the variable with additional delimiters as necessary.
If the variable being SET does not exist, it is treated as if it was equal to the null
string.
If the $PIECE function appears on the left side of the equal sign and the delimiter is
null, the following situations occur.
• If both First and Last are less than 1, the value of String remains unchanged.
• If First is less than 1 and it is less than Last, the value of String is replaced by
the value to the right of the equal sign.
• When First is equal to one and Last is less than 1, the value of String remains
unchanged. Otherwise, the value of String is replaced by the value to the right of
the equal sign.
Examples
Syntax
$QL{ENGTH}(Variable)
Definition
Variable An expression that evaluates to a local or global variable name.
The $QLENGTH function returns an integer value that indicates the total number of
subscripts in a local or global reference. If Variable contains no subscripts, the
function returns zero; otherwise, the function returns the total number of subscripts.
Associated Topics
Variables
$QSUBSCRIPT Function
Examples
Syntax
$QS{UBSCRIPT}(Variable,Position)
Definition
Variable An expression that evaluates to a local or global variable name.
Position An expression that specifies the position of the subscript in
Variable that is to be returned.
The $QSUBSCRIPT function returns the value of a subscript within Variable that is
specified by Position. If the value of Position is -1, the function returns environment
information if provided in Variable. If the value of Position is 0, the function returns
the local or global name unsubscripted and without environment information. If the
value of Position is greater than the total number of subscripts in Variable, the
function returns a null string.
Associated Topics
Variables
$QLENGTH Function
Examples
Syntax
$Q{UERY}(Variable{,Direction})
Definition
Variable An expression that evaluates to a subscripted local or global
variable name.
Direction An expression that evaluates to either 1 or -1.
The $QUERY function is used to identify the next or previous node in a local or
global variable that is defined and has data. The Variable name that is specified as an
argument to the function must be a local or global variable, and naked references are
allowed. If Direction is not specified, or if it evaluates to a value of 1, the system
returns the full local or global reference (variable name and subscripts) of the first
node that has data and follows the node specified by the Variable. If there is no node
following the node specified by the Variable reference, the system returns a null
value (""). If Direction is specified and has a value of -1, the system returns either the
previous node or null if there is no previous node. If Direction is specified and has
any value other than 1 or -1, an error condition occurs.
Associated Topics
Variables
Syntax
$R{ANDOM}(Integer)
Definition
Integer An integer expression that indicates the interval from which the
random number is generated.
The $RANDOM function returns a random or pseudo-random integer value that is
greater than or equal to 0 and strictly less than Integer. If the value of Integer is equal
to 1, the function returns 0. If the value of Integer is less than 1, an error condition
occurs.
Examples
Syntax
$RE{VERSE}(String)
Definition
String A string-type expression.
The $REVERSE function returns a string whose characters are in reverse order of the
characters contained in the specified String. The $REVERSE function is
computationally equivalent to the $$REV(EXPR) extrinsic function that is defined by
the following code.
REV(E) Q $S(E="":"",1:$$REV($E(E,2,$L(E)))_$E(E,1))
Computationally equivalent means that the result of the $REVERSE function is the
same as if the code provided in the $$REV(EXPR) extrinsic function were to be
successfully executed by an M process.
Examples
Syntax
$S{ELECT}(Condition:Expression{,...})
Definition
Condition A truth-valued expression.
Expression Any type of expression.
The $SELECT function processes the arguments in a left-to-right sequence and
evaluates each Condition until it finds one that is true (its truth-value is 1). If no true
Condition is found, an error occurs. No evaluation of the Expression associated with
the Condition occurs until a true Condition is found. The Expression associated with
the true Condition is then evaluated and returned by the function. No other Condition
or Expression following the true expression is evaluated.
Associated Topics
Truth-Valued Expressions
Examples
Syntax
$ST{ACK}(Level{,StackCode})
Definition
Level An integer expression that specifies the execution level for which
information should be returned.
StackCode A string expression that specifies the type of information to be
returned.
The single operand $STACK function provides the following information about the
execution stack.
• If the Level evaluates to -1, the function returns the current execution nesting
level. The $STACK special variable returns the same value as $STACK(-1).
• If the Level evaluates to 0 and if the partition was initiated via the JOB
command, the function returns 1. Otherwise, it returns 0.
• If the Level evaluates to a positive integer that is less than or equal to $STACK(-
1), the function returns a value that indicates how the current execution level was
initiated. If initiated by a command, the function returns the name of the
command fully spelled out and in uppercase (for example, DO or XECUTE).
Otherwise, it was initiated by an extrinsic function or variable, and the function
returns $$.
• If the Level evaluates to a value greater than $STACK(-1), the function returns
an empty string.
• All other values of Level are reserved for future extensions.
The two-operand $STACK function provides information about the execution level
specified using the first operand. The second operand specifies which information to
return. This operand can be in uppercase, lowercase, or mixed case.
• If StackCode evaluates to ECODE, the function returns the list of error codes
added at this level or the empty string.
• If StackCode evaluates to MCODE, the function returns the text of the line
identified by $STACK(Level,"PLACE").
• If StackCode evaluates to PLACE, the function returns the last command
executed at the specified level. If the location is a routine line, the format of the
function value is label+offset^routine. If the location is an XECUTE command
string, the function returns the at-sign character (@).
• All other values of StackCode are reserved for future extensions.
Associated Topics
$ECODE Special Variable
$ETRAP Special Variable
Appendix B, Error Processing
The last error occurred five lines past the label ERR in routine
ERRHAND.
Syntax
$T{EXT}(EntryRef)
Definition
EntryRef A line label or a plus sign followed by a line number, optionally
followed by a circumflex (^) and a routine name.
The $TEXT function returns the text of the line in the routine specified by the
EntryRef argument. The EntryRef can be either a line label (for example, ABC), a
line label plus an offset (for example, ABC+5), or an offset of the form +line number
(for example, +6). Optionally, any of these formats can be followed by a circumflex
(^) and a routine name (for example, ABC^MYPROG, ABC+5^CUSTINV,
+6^%STATUS). The returned text is in one of the following forms:
labelSP...SPtext
SP...SPtext
If the specified line reference does not exist or is beyond the last line of the routine,
the function returns a null string. If a routine name is specified and it does not exist,
the function returns a null string. The correct number of space characters is preserved
to match the number entered when the line was created.
Examples
The following line of code writes out the entire routine contained in the partition to the
current device.
F I=1:1 S X=$T(+I) Q:X="" W X,!
Syntax
$TR{ANSLATE}(String,From{,To})
Definition
String Any string-type expression.
From A string-type expression that specifies the characters to be replaced.
To A string-type expression that specifies the replacement characters.
The $TRANSLATE function takes each character from left-to-right in the From
string (the translate from character) and changes each occurrence of that character in
the String to a new character. The first character in From is translated to the first
character in To, the second to the second, the third to the third, and so on. If the
length of the From string is greater than the To string, then any characters in From
which have no corresponding character in To are removed from String. If To is not
specified, every character in From is removed from String. If the length of To is
greater than From, the extra characters in the To string are ignored.
Associated Topics
$LENGTH Function
Examples
Syntax
$V{IEW}(Address{,Domain{,Length{,Type}}})
Definition
Address An integer expression that is a memory address.
Domain An integer expression that defines the logical type of memory from
which the data is to be retrieved.
Length An integer expression that indicates the number of contiguous
memory locations to be retrieved.
Type An integer expression that indicates the format of the data to be
returned.
The $VIEW function is used to inspect the contents of system memory. The Domain
argument specifies the logical area of memory to be inspected, and the Address
argument specifies the offset into the area in bytes. A Domain of -1, -2, or -3
indicates an absolute real memory address; -4 indicates the constant area within the
Svector; -5 indicates the variable area within the Svector; 0 indicates the view buffer;
and a number greater than 0 indicates a partition (1 is job 1, 2 is job 2, and so on). If
the Domain is not specified, a value of -3 is assumed.
The Length argument specifies the number of bytes to retrieve. If it is omitted, a
length that corresponds to the natural word size of the machine being used is
assumed. The Type argument indicates the format in which the data is to be returned.
A value of 0 indicates decimal, 1 indicates string, 2 indicates hexadecimal, and 3
indicates binary. If omitted, a decimal value is assumed.
Considerations
When the default values for Length are used, the code may not be portable between
different implementations of MSM because the natural word sizes are different.
Associated Topics
Chapter 6, Special Variables
Syntax
$ZBN(Name)
$ZBN("",Block{,Owner{,VolNum}}})
Definition
Name A routine name or a global variable name.
Block An integer expression that indicates a disk block number.
Owner An integer expression that specifies the UCI index number of the
owner, 255 to indicate a system-owned block, or 254 to indicate a
non-database block, and so on.
VolNum An integer expression that specifies the index number of the volume
group.
The $ZBN function returns the starting block number (the disk address of the highest
level pointer block) for a specified global variable or the block number of a routine's
header block. The global variable name must be unsubscripted and preceded by a
circumflex (^). For routine names, a circumflex followed by a space and the name in
parenthesis (for example, ^ ("MYPROG")) is used to indicate that the Name is a
routine.
If the Name argument is "", the system allocates or deallocates the disk block. If
Block is greater than zero, the system searches for a free disk block and allocates the
first free block that is found. The search for a free block begins with the map block
specified by the Block argument.
When the allocation is done within the current UCI (the Owner parameter is not
specified on the $ZBN function), the block is allocated within the limits of the
expansion pointers for the current UCI. If the VolNum parameter is specified, the
system allocates the specified block within the specified volume group. Otherwise, it
allocates the block within the current volume group.
If the Block number is less than zero, the system deallocates the specified block.
When a block is deallocated, the Owner parameter is ignored. However, the VolNum
parameter is honored. For both allocation and deallocation of blocks, the system
always returns the number of the affected Block. For deallocation of blocks, this
number is negative.
Associated Topics
Chapter 7, Structured Variables
Syntax
$ZBname(BitParm{,BitParm{,BitParm}})
Definition
Name The name of the bit function that is to be performed.
BitParm An expression that evaluates to a function-specific parameter.
Each bit string function accepts from one to three BitParm parameters. The
parameters specified for a function are specific to the function being performed. Each
specified BitParm parameter must be one of the following.
BitStr An expression that evaluates to a bit string. If the function accepts
more than one BitStr as a parameter, the BitStr parameters are
specified as BitStr1, BitStr2, etc.
BitVal An expression that evaluates to a value of 0 or 1. Any other value is
invalid.
BitPos An expression that evaluates to a position within a bit string. The first
position in a bit string is 1, the second is 2, and so on.
BitSize An expression that evaluates to a number equal to the total number of
0 and 1 bits in a bit string.
The $ZBname function implements a variety of operations that work on bit strings. A
bit string is defined as a string that contains any quantity of zeros and ones (any
quantity of BitVals as defined above) concatenated together in any order. No other
values can be present in the string. MSM packs each eight bits in a bit string into a
one-byte character. All BitStrings are rounded up to multiples of eight BitVals
(BitStrings are maintained internally as character strings).
$ZBA{ND}(BitStr1,BitStr2)
The $ZBAND function returns a bit string that is the result of logically ANDing the
string specified by the BitStr1 parameter with the string specified by the BitStr2
parameter. The length of the resulting bit string is equal to the length of BitStr1, if the
length of BitStr1 is less then the length of BitStr2. Otherwise, it is equal to the length
of BitStr2.
Associated Topics
$EXTRACT Function
$FIND Function
$LENGTH Function
Examples
Syntax
$ZB{OOLEAN}(String1,String2,Mask)
Definition
String1 Any string-type expression.
String2 Any string-type expression.
Mask An integer expression that identifies the Boolean operation to be
performed.
The $ZBOOLEAN function performs a bit-by-bit logical operation specified by the
Mask on the String1 and String2 arguments. The specified Boolean operation is a bit
mask that corresponds to the four possible states of two binary bits. The following
table lists the possible combinations and the corresponding Mask value.
=%22/($1 0DVN 9DOXHV
By combining values from the above table, the value of the Mask can range from 0 to
15, inclusive. If any of the conditions specified by the Mask are true, then the
corresponding bit in the string that is returned is set to 1. The length of the string that
is returned is always equal to the length of String1. If the length of String2 is less than
the length of String1, String2 is repeatedly applied to String1. The following table
illustrates all of the possible Mask settings and their associated logical operations.
Mask $ZBOOLEAN(A,B,Mask)
0 0
1 A∧B
2 A ∧ ¬B
3 A
4 ¬A ∧ B
5 B
6 A⊗B
7 A∨B
8 ¬A ∧ ¬B ≅ ¬ (A ∨ B)
9 ¬ (A ⊗ B) ≅ ¬A ⊗ ¬B
10 ¬B
11 A ∨ ¬B
12 ¬A
13 ¬A ∨ B
14 ¬ (A ∧ B) ≅ ¬A ∨ ¬B
15 1
Associated Topics
$LENGTH Function
Note Although $ZCALL has been superseded by the ANSI standard External Call
syntax, support for $ZCALL is still provided.
Syntax
$ZC{ALL}(Function{,Parm, ... , Parm})
Definition
Function The name of the function to be called. This is the function's actual
name without quotation marks.
Parm One or more parameters to be passed to the function.
The $ZCALL function is used to call an external, user-supplied routine to perform an
operation. This function is provided for backwards compatibility. It has been
superseded by the new external routine call syntax.
Examples
Syntax
$ZCR{C}(String{,Type{,Initvalue}})
Definition
String Any string-type expression.
Type An integer expression that indicates the type of checksum to be
performed on the string. The default value is 0 (Exclusive OR).
Initvalue An integer expression that is added to the result of the CRC
calculation (only valid for types 5, 6, and 32).
The $ZCRC function computes four types of checksums: Exclusive OR, ASCII
summation, 16-bit CRC, and 32-bit CRC.
&KHFNVXP 7\SHV
Type Checksum
0 Exclusive OR
1 ASCII summation
5 16-bit CRC (DTM-compatible)
6 16-bit CRC (DSM-compatible)
32 32-bit CRC
Associated Topics
$ASCII Function
Examples
Syntax
$ZCRE{ATEOBJECT}(ClassName)
Definition
ClassName A string-type expression that specifies the class of the object to
be instantiated.
This function is available only on platforms that support OLE/2 objects.
By convention, the format of the ClassName parameter is as follows.
AppName.ObjectType
Every application that supports OLE/2 automation provides at least one type of
object. For example, a word processing application may provide an application
object, a document object, and a toolbar object.
$ZCREATEOBJECT is used when there is no current instance of the object. The
$ZGETOBJECT function is used if there is a current instance or if the application is
to be started and is then to load a file.
Associated Topics
SET Command
ZSETOBJ Command
$ZGETOBJECT Function
Example
M Code Description
SET X=$ZCRE("word.Basic") Creates a Word 6.0 document object.
I $ZOBJREF(X)=0 G ERROR Ensures allocation succeeded.
S X.Insert="Hello World" Inserts a line.
S X.FileSaveAs="C:\hello.doc" Saves the file.
Syntax
$ZD{ATE}(Integer{,Type})
Definition
Integer An integer expression that is in $HOROLOG format.
Type An integer expression that indicates the format for the external date.
The $ZDATE function converts the Integer value, which is assumed to be the
number of days since December 31, 1840, to an external date format. The external
form is determined by the value of the Type argument. Type has the following
meanings.
1 MM/DD/YY where MM is the month, DD is the day, and YY is the year.
2 DD MMM YY where DD is the day, MMM is the three-character
abbreviation for the month, and YY is the year.
3 DD/MM/YY is the European form of the date, where DD is the day, MM
is the month, and YY is the year.
If the Type is omitted, a value of 1 is assumed. If the year is in the current century,
the century is not displayed.
Associated Topics
$HOROLOG
Syntax
$ZDE{VICE}(Integer)
Definition
Integer An integer expression that evaluates to a device number.
The $ZDEVICE function returns the full name of a terminal device. The Integer
value that is specified is the actual MSM device number. If the device does not have
an external name, the device number is returned.
Associated Topics
$PRINCIPAL Special Variable
Using Peripheral Devices, MSM User's Guide
Examples
Syntax
$ZGETO{BJECT}({PathName}{,ClassName})
Definition
PathName A string-type expression that specifies the full pathname and filename
of the file that contains the object to be instantiated.
ClassName A string-type expression that specifies the class of the object to be
instantiated.
This function is available on platforms that support OLE/2 objects.
If the PathName parameter is omitted, the ClassName parameter must be supplied.
If PathName is a zero-length string (""), $ZGETOBJECT returns a new object
instance of the specified type. If the PathName argument is omitted entirely,
$ZGETOBJECT returns a currently active object of the specified type. If an object of
the specified type does not exist, an error occurs (no object is created). By
convention, the path name can include a suffix of the form: !name. The name portion
of the file is used to activate the object.
If the object's class is not specified, OLE/2 uses the filename provided to determine
the application to start and the object to activate. Some files can support more than
one class of object. For example, a drawing might support three types of objects: an
application object, a drawing object, and a toolbar object, all of which are part of the
same file. The optional ClassName argument can be used to specify which object in a
file is to be activated.
$ZGETOBJECT is used if there is a current instance of the object and if the object is
to be created with a loaded file. If there is no current instance and the object is not to
be started with a file loaded, the $ZCREATEOBJECT function is used.
Associated Topics
SET Command
ZSETOBJECT Command
$ZCREATEOBJECT Function
Setup Description
ZSET X=$ZGETO("c:\cad\schema.cad") Instantiates an object in schema
file.
ZSET Activates layer 3 within the
X=$ZGETO("c:\cad\schema.cad!Layer3")
schema file.
ZSET X=$ZGETO("d:\drawings\ FIGMENT is the name of the
sample.drw","FIGMENT.DRAWING")
drawing application, and
DRAWINGS is one of the object
types it supports.
ZSET X=$ZGETOBJECT(,"FIGMENT.DRAWING") Locates an active object of the
G:$ZOBJREF(X) GOTOBJ
FIGMENT.DRAWING class.
ZSET X=$ZGETO("","FIGMENT.DRAWING") Creates a new instance of a
FIGMENT.DRAWING class.
Syntax
$ZH{EX}(Expression)
Definition
Expression An expression that evaluates to a string or an integer.
The $ZHEX function converts a hexadecimal value to decimal or a decimal value to
hexadecimal. If the Expression evaluates to a string, then the conversion is from
hexadecimal to decimal. If the Expression evaluates to an integer, then the
conversion is from decimal to hexadecimal.
Considerations
When converting from hexadecimal to decimal, the string may contain numbers from
0 through 9 and letters from A through F in uppercase, lowercase, or a mixture of the
two; otherwise, the function returns 0.
Associated Topics
HEXADECIMAL Operator
Examples
Syntax
$ZHL (Type,Format_String,{$H_Value})
Definition
Type Type of format to perform: 1 - date, 2 - time.
Format_String Date or time formatting token. In this string, the replacement
tokens listed in the following tables are used to specify the parts
of the date or time to be returned. Any punctuation characters
are copied to the result unchanged. The punctuation and tokens
can be in any order. The tokens can be combined in any order in
the format string and can be repeated. The string cannot contain
other sequences of characters.
The $ZHL function allows the caller to control the format of the external date or
time. For each call, the function converts only a single date or time.
The following token strings apply to date formatting and are only valid when Type is
one. Different cases produce different results.
'DWH )RUPDW 6WULQJV
The following token strings apply to time formatting and are only valid when Type is
two. Different cases produce different results.
7LPH )RUPDW 6WULQJV
Associated Topics
ZHOROLOG Command
$HOROLOG Special Variable
$ZDATE Function
Syntax
$ZN{EXT}(Variable{,Direction})
Definition
Variable An expression that evaluates to a subscripted local or global variable
name.
Direction An expression that evaluates to either 1 or -1.
The $ZNEXT function is used to identify the next or previous node in a local or
global variable that is defined and has data. The Variable name that is specified as an
argument to the function must be a local or global variable, and it must be a full
reference. If Direction is not specified or if it evaluates to a value of 1, the system
returns the full local or global reference (variable name and subscripts) of the first
node that has data and follows the node specified by the Variable. If there is no node
following the node specified by the Variable reference, the system returns a value of
-1. If Direction is specified and has a value of -1, the system either returns the
previous node or -1 if there is no previous node. If Direction is specified and has any
value other than 1 or -1, an error condition occurs.
The $ZNEXT and $ZORDER functions perform identical operations. The only
difference is in the starting and ending values of the functions. In the case of
$ZNEXT, the starting and ending value is -1. For $ZORDER, the null value is used
to indicate the starting and ending points. The $ZNEXT and $QUERY also are
identical except for the reason identified above.
Associated Topics
Variables
$NEXT Function
$QUERY Function
$ORDER Function
$ZORDER Function
Syntax
$ZOB{JREFERENCE} (Expression{,Expression})
Definition
Expression Any M expression.
If only one argument is specified, $ZOBJREFERENCE returns 1 if the Expression
evaluates to an object reference or returns 0 if it does not. If two arguments are
specified, $ZOBJREFERENCE returns 1 if both Expressions evaluate to references
to the same object; otherwise, it returns 0.
Examples
Syntax
$ZO{RDER}(Variable{,Direction})
Definition
Variable An expression that evaluates to a subscripted local or global
variable name.
Direction An expression that evaluates to either 1 or -1.
The $ZORDER function is used to identify the next or previous node in a local or
global variable that is defined and has data. The Variable name that is specified as an
argument to the function must be a local or global variable and it must be a full
reference. If Direction is not specified or if it evaluates to a value of 1, the system
returns the full local or global reference (variable name and subscripts) of the first
node that has data and follows the node specified by the Variable. If no node follows
the node specified by the Variable reference, the system returns a value of null ("").
If Direction is specified and has a value of -1, the system either returns the previous
node or null if there is no previous node. If Direction is specified and has a value
other than 1 or -1, an error condition occurs.
The $ZORDER and $ZNEXT functions perform identical operations. The only
difference is the functions' starting and ending values. For $ZORDER, the starting
and ending value is null. For $ZNEXT, a -1 value specifies the starting and ending
points. The $ZORDER and $QUERY functions are identical.
Associated Topics
Variables
$NEXT Function
$ORDER Function
$QUERY Function
$ZNEXT Function
Syntax
$ZOS(OptNum{,Opt1{,Opt2{,Opt3}}})
Definition
OptNum An integer expression that indicates the Windows function to be
performed.
Opt1 An optional parameter whose format and contents are specific to the
Windows function that the system is performing.
Opt2 An optional parameter whose format and contents are specific to the
Windows function that the system is performing.
Opt3 An optional parameter whose format and contents are specific to the
Windows function that the system is performing.
If the $ZOS function fails, it returns a negative error number, where the error number
is the return code received from the corresponding Windows system function.
Common error codes that can be received are described later in this section.
The following subsections describe the Windows functions that can be invoked from
MSM, the parameters that must be supplied for each function, and the value returned
upon successful completion of the function.
Note Unpredictable results can occur if the MSM database files that the system is
using are deleted.
Rename a File
This function renames a file within the Windows file system. File attributes are
honored by the system so that read-only files cannot be renamed. This function is
equivalent to the RENAME command in Windows. The following is the syntax for
the Rename a File function.
$ZOS(3,OldFile,NewFile)
OldFile is the name of the file to be renamed. OldFile optionally can include a
DriveID and a directory path.
NewFile is the new name of the renamed file. NewFile optionally can include a
directory path. If a specified path is different than the path supplied or implied in the
OldFile, the file is moved to the new directory. If a DriveID is specified, it must be
the same as the DriveID associated with the OldFile name.
The following example illustrates this function.
$ZOS(3,"FILE.DAT","FILE.BAK") Renames file to .BAK file
$ZOS(3,"\UTL\PROG","\OLD\PROG") Moves PROG file
$ZOS(3,"C:\ABC","C:\XYZ") Renames ABC on C:
If the function is successful, it returns 0 to indicate the file was renamed. Otherwise,
the function returns an error code of -2 to indicate file not found, -3 to indicate path
not found, -5 to indicate that access was denied, or -17 if files are not on the same
device.
Note Unpredictable results can occur if the MSM database files the system is using
are renamed.
If the function is successful, it returns a string in the form S1^S2, in which S1 is the
FileName that was found and S2 is a character string that is used as input to the
Continue Directory Search function. Otherwise, the function returns an error code of
-2 to indicate invalid path or null to indicate no matching directory entry found. S2
also contains file information in the same format as MSM-PC/PLUS.
$A(S2,22) = File attributes
$E(S2,23,24) = File time in MS-DOS format
$E(S2,25,26) = File date in MS-DOS format
$E(S2,27,30) = File size, least significant byte first
If the function is successful, it returns a string in the form S1^S2, where S1 is the
FileName that was found and S2 is a character string that is used as the next
SearchParm to this function. Otherwise, the function returns an error code of -2 to
indicate invalid path or -12 to indicate no matching directory entry found.
If the function is successful, it returns the current drive as a single character (for
example, A). Otherwise, it returns a negative error code.
Number Description
-1 Invalid function
-2 File not found
-3 Path not found or invalid
-4 Too many open files
-5 Access denied
-6 Handle is invalid
-8 Insufficient memory
-11 Format invalid
-12 Access code invalid
-14 Unknown unit
-15 Disk drive invalid
-16 Attempt to remove the current directory
-17 Not same device
-18 No more files
-19 Disk write-protected
Syntax
$ZPO{SITION}(String,Field{,Width})
Definition
String Any string type expression.
Field An integer expression that specifies the size of the output field.
Width An expression that specifies the relative width of a double-byte
character, when compared with a single-byte character.
The $ZPOSITION function is used to determine the number of characters of a String,
beginning with the first, can fit into a fixed-length field of an output device. The
Field argument specifies the size of the output field in single-byte character positions.
Considerations
The result of $ZPOSITION can be used in $EXTRACT to truncate a string so that it
fits within a given field. For example, if $ZPO(string,20,2)=15, then $E(string,1,15)
will fit in a field that is 20 positions long.
Associated Topics
$ZWIDTH
Examples
In the following examples, the symbol ❖ is used to represent a double-byte character.
$ZPO("❖❖❖abcde",20,2) 8
$ZPO("❖❖❖abcde",8,1.25) 7.25
$ZPO("❖❖❖abcde",8,1.5) 6.5
$ZPO("❖❖❖abcde",8,2) 5
$ZPO("❖❖❖❖❖❖❖",7,1.25) 5.6
$ZPO("❖❖❖❖❖❖❖",7,1.5) 4.6666666666666666
$ZPO("❖❖❖❖❖❖❖",7,2) 3.5
Syntax
$ZP{REVIOUS}(Variable)
Definition
Variable An expression that evaluates to a subscripted local or global variable name.
The $ZPREVIOUS function is used to identify the previous subscript in sequence at
a given level. The Variable name that is specified as an argument to the function can
be subscripted, and naked references are allowed. For the right-most subscript in the
Variable, the system returns the subscript value that precedes it. If no subscript
precedes it, the function returns a null value. If the right-most subscript in the
reference is a null value, then the system returns the value of the last subscript at that
level. This function is identical to the $ORDER function with a second operand of -1
and is provided only for compatibility with other M implementations.
Associated Topics
Variables
$NEXT Function
$ORDER Function
$QUERY Function
$ZNEXT Function
$ZORDER Function
$ZSORT Function
Syntax
$ZS{ORT}(Variable{,Direction})
Definition
Variable An expression that evaluates to a local or global variable
name.
Direction An expression that evaluates to either 1 or -1.
The $ZSORT function is used to identify the next or previous subscript in sequence
at a given level. The Variable name that is specified as an argument to the function
must be subscripted, and naked references are allowed. If Direction is not specified
or has a value of 1, then for the right-most subscript in the Variable, the system
returns the next subscript value that follows it. If no subscript follows it, the function
returns a null value. If the right-most subscript in the reference is a null value, the
system returns the value of the first or last subscript at that level, depending on the
value of Direction. If Direction is specified and evaluates to -1, the function returns
the previous subscript for the variable. If Direction is specified and has any value
other than 1 or -1, an error condition occurs.
The $ZSORT function returns the subscripts in the collating sequence defined for the
global (string or numeric sequence). For local variables, the subscripts are always
returned in string-collating sequence. The $ORDER function is identical to $ZSORT,
except that for local variables, it returns the subscripts in numeric-collating sequence.
Associated Topics
Variables
$NEXT Function
$ORDER Function
$QUERY Function
$ZNEXT Function
$ZORDER Function
Syntax
$ZU{CI}(UCIName{,VolName})
$ZU{CI}(UCINum{,VolNum})
Definition
UCIName A string expression that is an external UCI name.
VolName A string expression that specifies a three-character volume group
name.
UCINum A numeric expression that is an internal UCI number.
VolNum A numeric expression that specifies an internal volume-group
number.
In the first form, the $ZUCI function returns the internal reference number of the
specified user-class identifier, followed by the internal reference number of the
volume group containing the UCI. These fields are separated by a comma. If the
VolName is passed to the function, that volume group is searched for the specified
UCI; otherwise, the current volume group is searched. If the UCIName or the
VolName is invalid or does not exist, the function returns the null string. If the
UCIName is null, the current UCI is used.
In the second form, the $ZUCI function returns the external name of the specified
UCI number followed by the external name of the volume group that contains the
UCI. These fields are separated by a comma. If a VolNum is passed to the function,
that volume group is searched for the specified UCI. Otherwise, the current volume
group is searched. If the UCINum or the VolNum is invalid or does not exist, the
function returns a null ("") value. If the UCINum is 0, then the current UCI is
returned. If the UCINum is equal to the null string, then the numeric form of the
current UCI is returned.
Associated Topics
Using Peripheral Devices, MSM User's Guide
Syntax
$ZV{ERIFY}(Block{,Count{,VolNum}})
Definition
Block An integer expression that indicates the starting disk block number.
Count An integer expression that specifies the maximum number of errors
to be reported.
VolNum An integer expression that specifies an internal volume group
number.
The $ZVERIFY function returns a string that contains a list of errors, if any, that
exist within the MSM database. The Block argument indicates the disk block number
where the verify operation is to begin. The function starts with the specified Block
and verifies the internal structure and integrity of the Block and all descendants of the
Block. If an error is detected, a string is returned that contains information about the
error. This string is in the following form.
ErrCode,BlockNum,Offset
In the error string, ErrCode is an integer number that identifies the type of error;
BlockNum is the block number of the error; and Offset is the offset into the block
where the error was found. The Count argument is used to specify the maximum
number of errors that are to be returned by the function. Any integer value can be
specified. When multiple errors are returned, they are separated from each other by a
circumflex ( ^ ). If the Count is omitted, a value of 1 is assumed.
The VolNum argument is used to specify the volume group that contains the Block
that is to be verified. If this argument is omitted, the current volume group is
assumed.
Considerations
The BlockNum returned by the function contains the entire path to the bad block. The
format of BlockNum is #1:#2:#3:...:#n where #2 is the parent of #1, #3 is the parent
of #2, and so on.
Examples
Syntax
$ZW{IDTH}(String{,Width})
Definition
String Any string-type expression.
Width An expression that specifies the relative width of a double-byte
character compared to a single-byte character.
The $ZWIDTH function is used to calculate the number of character positions that a
string occupies when it is displayed on a specific output device. A single-byte
character is assumed to occupy one position on the output device. The Width
argument specifies how many positions a double-byte character occupies on the
output device. If Width is omitted, it is assumed to be two.
If n1 is the number of double-byte characters in String and n2 is the number of
single-byte characters in String, then $ZWIDTH(String,Width)=n1*Width+n2.
Associated Topics
$ZPOSITION
Examples
In the following examples, the symbol ❖ is used to represent a double-byte character.
Setup Value of
Function
$ZWIDTH("",2) 0
$ZW("❖❖❖abcde",1.25) 8.75
$ZW("❖❖❖abcde",1.5) 9.5
$ZW("❖❖❖abcde",2) 11
$ZW("❖❖❖abcd",2) 10
Overview
The M language provides special variables that are maintained by MSM and can be
accessed by the programmer. These special variables are designed to provide
feedback information to executing programs as they interact with the system and
specify system behavior. These variables can be examined by the program using M
commands, and based on their values, decisions can be made within the program.
MSM provides all of the ANSI-standard special variables and an extended set of
special variables that are specific to MSM. The ANSI-standard special variables
begin with a dollar sign ($) followed by the letters A through Y, and the
MSM-specific special variables begin with a dollar sign and the letter Z. Special
variable names be spelled out or can be abbreviated as specified by the ANSI
standard. Special variable names can be specified in uppercase, lowercase, or a
combination of uppercase and lowercase. For example, the following are all valid
abbreviations.
$STORAGE
$SToRAge
$S
$s
The following sections describe the special variables provided in the MSM system.
For additional information about device-specific special variables, refer to "Using
Peripheral Devices," in the MSM User's Guide.
Syntax
$D{EVICE}
Definition
The $DEVICE special variable contains a string that indicates whether the last device
handling mnemonic input/output operation was successful. The string value of
$DEVICE is in the following format.
MDC#,Implementor#,Descriptive Text
The MDC# is a value defined by the M Development Committee in an effort to
standardize error conditions. The Implementor# is defined by Micronetics to further
describe the nature of an error. The Descriptive Text is a brief description of the error
that occurred. Refer to the information on mnemonic namespaces in "Using
Peripheral Devices," in the MSM User's Guide for a list of the MDC# errors and the
Implementor# errors.
Considerations
The value of $DEVICE, when interpreted as a truth value, is equal to zero if the
operation is successful. A non-zero value indicates that the operation failed. This
special variable has meaning only for devices that are associated with a mnemonic
namespace.
Associated Topics
WRITE Command
Using Peripheral Devices, MSM User's Guide
Examples
USE 5::"X3.64-1979" W /CUP(4,24) Q:$DEVICE
This example attempts to move the cursor to the specified location and QUITs if the operation
is not successful.
Syntax
$EC{ODE}
Definition
The $ECODE special variable contains a string that identifies the errors encountered
by the application. The string value of $ECODE is in the following format.
,ErrorCode1,ErrorCode2, ... ,
Note that a comma precedes and follows each error code. Error codes are in one of
the following formats.
Mnn where nn is an integer specified by the ANSI standard
Uxx where xx is any user-defined string not containing a comma
Zxx where xx is defined by the version of MSM (MSM-specific)
The M values are integer numbers specified by the 1994 ANSI M standard (and
subsequent Type A amendments) issued by the M Development Committee in an
attempt to standardize error conditions.
The U values are any user-defined strings that do not contain a comma. These are
typically application-specific error codes managed by application-specific error
handling routines that examine the value of $ECODE.
The Z values are implementation-specific error codes. For MSM, they are the same
values that are assigned by MSM to the $ZERROR special system variable.
Refer to Appendix B, "Error Processing," in this document for a list of the ANSI M
error numbers and MSM-specific error codes.
Considerations
When the value of $ECODE is the empty string, normal routine execution rules are in
effect.
Error processing is initiated when:
• $ECODE transitions from an empty to a non-empty string. The value of
$ECODE may change implicitly when MSM detects an error condition (such as
an undefined variable), or when explicitly SET by the application.
• A QUIT returns from an execution level with $ECODE non-empty to a level in
which no error had occurred. For example, $STACK(new level,"ECODE") is the
empty string.
• When the value of $ECODE is changed via the SET command, the new value
replaces the existing value. The replacement value must be in the correct format
as described above; otherwise, an error occurs.
• When a partition is initiated, $ECODE has the value of the empty string.
Examples
FOR I=2:1:$L($ECODE,”,”)-1 WRITE !,$P($ECODE,”,”,I)!,$P($ECODE,”,”,I)
This code displays the individual error codes in $ECODE on individual lines.
WRITE $ECODE
Syntax
$ES{TACK}
Definition
The $ESTACK special variable contains a non-negative integer specifying the
relative nesting of the current execution level. The value is automatically incremented
by the DO and XECUTE commands, and automatically decremented by the QUIT
command. The NEW command may be used to stack the current value and reset
$ESTACK to 0. A QUIT command (explicitly or implicitly at the end of a routine or
an XECUTE string) restores the stacked value. A new partition begins with
$ESTACK set to 0.
Refer to the MSM User's Guide for additional information.
Considerations
An application may stack the value of $ESTACK and reset it to 0 via the NEW
command. Subsequent error handling routines may "pop" the execution levels until
$ESTACK returns to 0, at which point execution returns to its initial starting level for
the application. This is useful for nested applications. If $ESTACK is not stacked by
the NEW command, it always equals $STACK.
Associated Topics
DO Command
JOB Command
NEW Command
SET Command
XECUTE Command
$STACK Special Variable
Using the MSM System, MSM User's Guide
This command pops the current execution level as long as $ESTACK is positive. Note that if
$ECODE has not been reset to the empty string, returning from an execution level with
$ECODE not null automatically invokes error handling for the returned-to execution level.
This command stacks the current $ESTACK value; resets the current value of $ESTACK to
zero; defines the error handling string; and invokes the application.
Syntax
$ET{RAP}
Definition
The $ETRAP special variable contains a string of M code to be executed when an
error condition is detected. The code is executed at the same execution level at which
the error occurs. Prior to execution of the string in $ETRAP, any active FOR loops
and indirections in the current execution level are terminated. Execution behaves as if
the contents of $ETRAP are appended to the current routine with a temporary but
unique label, and an internal GOTO to the appended code is performed. Updating
$ETRAP replaces its previous value.
The current value of $ETRAP can be stacked using the NEW command. The NEW
command does not alter the value of $ETRAP—it merely stacks it. New partitions
begin with $ETRAP set to the empty string. When $ETRAP is SET, the value of
$ZTRAP also is reset to the empty string so that at any time, either $ETRAP or
$ZTRAP defines the error handling environment, but not both.
Refer to the MSM User's Guide for additional information.
Considerations
Within an application, the NEW command can be used to stack the caller’s $ETRAP
until a QUIT command (implicit or explicit) is executed at the current execution
level.
Unlike $ZTRAP, the value of $ETRAP is not tied to an execution level unless the
NEW command is used. Therefore, the application can set $ETRAP at the start of the
application. The same $ETRAP value is used at each nested level if an error
condition is detected. When initiating error processing, MSM performs an explicit
GOTO (without changing the execution level) to the following two lines of code.
...value of $ETRAP...
QUIT:$QUIT "" QUIT
Examples
NEW $ETRAP SET $ETRAP=“D ERR^ROUTINE”$ETRAP=“ERR^ROUTINE”
This example stacks the current value in $ETRAP and establishes a new string to be executed
if an error condition is detected.
Syntax
$H{OROLOG}
Definition
The $HOROLOG special variable contains the current date and time in the following
format.
Date,Time
The Date is the number of days since December 31, 1840, and the Time is the
number of seconds since midnight. The Time may range from a value of 0 (midnight)
to 86399 (11:59:59 PM).
Considerations
At midnight, the MSM system automatically increments the Date portion by one and
resets the Time portion to 0.
Associated Topics
$ZDATE Function
Examples
The following converts $H to an external date such as 14-MAY-90.
%D ;BPS;CONVERTS $H TO DD-MMM-YY;
;COPYRIGHT MICRONETICS DESIGN CORP. @1990
S %H=+$H,%H=%H>21914+%H
S %LY=%H\1461,%R=%H#1461,%Y=%LY*4+1841+(%R\365),%D
..........=%R#365,%M=1
I %R=1460,%LY'=14 S %D=365,%Y=%Y-1
F %I=31,(%R>1154)&(%LY'=14)+28,31,30,31,30,31,31,3
..........0,31,30 Q:%I'<%D S %M=%M+1,%D=%D-%I
I %D=0 S %Y=%Y-1,%M=12,%D=31
S %DAT1=%D_"-"_$P("JAN FEB MAR APR MAY JUN JUL AUG
..........SEP OCT NOV DEC"," ",%M)_"-"_$E(%Y,3,4)
S %DAT=%M_"/"_%D_"/"_%Y
K %D,%H,%I,%LY,%M,%R,%Y,%NP Q
Syntax
$I{O}
Definition
The $IO special variable contains the device number (designator) of the current
device for the job. The value of $IO is uniquely identified for the current input/output
device. The current input/output device is the device most recently referenced with
the USE command. If a USE command has not been issued, the current device
number corresponds to the principal device number (the device number assigned to
the job when it logged onto MSM).
Associated Topics
OPEN Command
CLOSE Command
USE Command
ZUSE Command
$PRINCIPAL Special Variable
Examples
USE 3 S X=$I
S ^A($I,1)=X
Syntax
$J{OB}
Definition
The $JOB special variable contains the job number of the current job. When a user
logs onto MSM, a job is created and a unique integer number is assigned to the job.
In addition, whenever a job is started with the JOB command, a unique job number is
assigned to the newly created job.
Associated Topics
JOB Command
Examples
S ^A($J,1)=X
It is a common practice to store application global data that is only needed for a short time in a
"temporary" global, using $JOB as the first index.
Output from a job can be identified by printing the job number with the output.
Syntax
$K{EY}
Definition
The $KEY special variable contains the sequence of control characters that
terminated the last READ command from the current device. Before the first READ
is issued to a device or when the READ terminates without receiving a terminator
character (for example, as a result of a timeout, a fixed-length READ, or a single-
character READ operation), the value of $KEY is the null string (empty). Otherwise,
it is one of the control characters that can be specified in MSM as a READ
terminator. When escape processing is enabled for terminal devices, $KEY can
contain a string of characters, usually generated by a function key, which terminated
the READ.
Considerations
This special variable has meaning only for devices that are associated with a
mnemonic namespace.
Associated Topics
READ Command
USE Command
Using Peripheral Devices, MSM User's Guide
Examples
USE 5::"X3.64-1979" W /CUP(4,24) R X Q:$KEY'=$C(13)
This example moves the cursor to the specified location; READs a value into variable X; and
QUITs if the operation was not terminated by the RET key.
When escape processing is turned on by the USE command, $KEY can contain a string of
characters.
Syntax
$P{RINCIPAL}
Definition
The $PRINCIPAL special variable contains the number of the device that was the
principal device at the instant that the job was started. In other words, $PRINCIPAL
is equal to the initial value of the $IO special variable.
In the case of a job that was created as a result of a user logging into MSM, it is the
number of the device that initiated the logon. For a job created as a result of the JOB
command, it is the device number of the principal device associated with the job that
issued the command.
Considerations
The $PRINCIPAL special variable supersedes the old convention in MSM where a
USE 0 command indicates the principal device. This construct should be replaced
with a USE $PRINCIPAL statement to ensure portability.
Associated Topics
JOB Command
$IO Special Variable
Examples
USE $PRINCIPAL
This example makes the initial device for the job (the principal device) the current device.
C:$I'=$P $I
This example closes the current device if it is not the principal device.
Syntax
$Q{UIT}
Definition
The $QUIT special variable indicates if an argument is required on a QUIT. $QUIT
returns 1 if the current execution level was invoked as an extrinsic and a QUIT
therefore requires a value. Otherwise, $QUIT returns 0. $QUIT is initialized to 0
when a process is started.
Associated Topics
Extrinsic Functions
Parameter Passing
$ECODE Special Variable
$ESTACK Special Variable
$ETRAP Special Variable
$QUIT Special Variable
$STACK Special Variable
$STACK Function
Examples
TEST ;$QUIT example
SET $ETRAP="DO ER^TEST"
READ !,"Enter name: ",A
SET A=$$STRIP(A) Q:A=-1
A READ !,"Enter phone number: ",B
IF B'?4.20NP WRITE *7 GOTO A
QUIT
STRIP(A) ; strip spaces at either end
FOR QUIT:$ASCII(A)'=32 SET $EXTRACT(A)=""
FOR QUIT:$A(A,$LENGTH(A))'=32 S $E(A,$L(A))=""
QUIT A
ER W !,"Error: ",$ECODE S $ECODE=“”
QUIT:$QUIT -1 ; end of extrinsic function
QUIT
In the preceding routine, error recovery is simplified by using the $QUIT variable. If an error
occurs within the extrinsic function, the function can be terminated properly with a QUIT
argument, depending on the value of $QUIT. This feature enables the user to avoid placing a
second error trap within the extrinsic function.
Syntax
$ST{ACK}
Definition
The $STACK special variable contains a non-negative integer that specifies the
absolute nesting of the current execution level. The value is automatically
incremented by the DO and XECUTE commands and is automatically decremented
by the QUIT command. A new partition begins with $STACK set to zero.
Refer to the MSM User's Guide for additional information.
Considerations
$STACK differs from $ESTACK in that the value is read-only and cannot be SET by
the application, nor can it be stacked by using the NEW command. $STACK reflects
the actual nesting level of the DO and XECUTE commands for the entire partition.
$ESTACK reflects a relative nesting level because it is reset by the NEW command.
If $ESTACK is not stacked by the NEW command, it always equals $STACK.
Associated Topics
DO Command
JOB Command
SET Command
XECUTE Command
$STACK Function
$ESTACK Special Variable
Using the MSM System, MSM User's Guide
Examples
WRITE !,$STACK($STACK,”ECODE”),!,$STACK($STACK,”MCODE”)
This example displays the error code generated at the current execution level. It also displays
the last line to generate an error in the current execution level.
Syntax
$S{TORAGE}
Definition
Each job is assigned a partition that is a specified size. The space within the partition
is used for the local symbol table of the job and the text of the routine, if any, that is
currently loaded into the partition through use of the ZLOAD or ZINSERT
commands. The $STORAGE special variable contains a decimal value, in bytes, that
represents the amount of space left in the partition after subtracting the size of the
local symbol table and the size of the routine text currently loaded into the partition.
Considerations
Refer to the MSM User's Guide for additional information on partition size.
Associated Topics
JOB Command
ZINSERT Command
ZLOAD Command
ZREMOVE Command
Variables
Examples
I $S<MINSIZE G ^FILETEMP
If the value of the $STORAGE variable falls below a specified minimum, then the FILETEMP
routine is invoked to temporarily file information in the partition.
If the value of the $STORAGE variable falls below 1000 bytes, then the %PARTSIZ routine
is invoked to increase the partition size.
Syntax
$SY{STEM}
Definition
The $SYSTEM special variable contains information that distinguishes in a unique
manner the current MSM system from all other MSM and non-MSM systems. The
$SYSTEM special variable contains two pieces separated by a comma. The first
piece is the Micronetics vendor identification number assigned by the M User's
Group. It will always be the value 43.
The second piece contains two numbers separated by a semicolon. The first number
is the serial number from the current MSM license. The second number is a unique
identifier for the current instance of MSM. This provides a unique value for
$SYSTEM when two workstation clients using the same license information connect
to a common server.
This special variable is formatted in such a way that it can be used directly as a
subscript in a local or global variable. When used in conjunction with the $JOB
special variable, network-unique nodes can be generated.
Associated Topics
Variables
Examples
WRITE $SYSTEM
43,1001234;176034223
S ^UTILITY($SY,$J)=X
Temporary global nodes can be set up with data stored by the SYSTEM identifier and the JOB
number.
Syntax
$T{EST}
Definition
The $TEST special variable contains a truth value that is either 0 (false) or 1 (true).
$TEST is set by execution of an IF command with an argument, or by an OPEN,
LOCK, JOB, READ, or ZALLOCATE command with a timeout. For the IF
command, if the argument of IF generates a true value, then $TEST is set to true;
otherwise, it is set to false. For timeouts, if the requested operation is completed
before the timeout, $TEST is set to true; otherwise, it is set to false. For the JOB
command, $TEST is set to true if the job was successfully started within the timeout
period; otherwise, it is set to false.
Considerations
Execution of a post-conditional expression on a command does not set the $TEST
special variable.
Associated Topics
ELSE Command
IF Command
JOB Command
LOCK Command
OPEN Command
READ Command
ZALLOCATE Command
Post-Conditionals Timeouts
Examples
I X=3 S Y=A
W:$T Y S Y=B
I X=3 S Y=A
I X=3 W Y
S Y=B
R X:100 G A:'$T DO B
In this example, $T is used to test whether the input was explicitly terminated before the
timeout expired. If there was no termination (if the input string is incomplete), execution
continues at A.
O 3::10 G A:'$T U 3 W X
This example is similar to example 2. If the OPEN is unsuccessful, execution transfers to label
A. Otherwise, output is written to device 3.
Syntax
$TL{EVEL}
Definition
The $TLEVEL special variable indicates whether or not a transaction is currently in
progress. This variable is initialized to 0 when the job (process) is started. A value of
0 indicates that no transaction is in progress for the job. Any other value indicates
that a transaction is in progress.
Whenever a TSTART command is performed, the system adds one to the current
value of the $TLEVEL variable. Whenever a TCOMMIT command is performed and
the value of $TLEVEL is greater then 0, the system subtracts one from the value of
the $TLEVEL variable. Whenever a TROLLBACK command or transaction restart
(an explicit TRESTART command or a system-initiated restart) is performed, the
value of the $TLEVEL variable is set to 0.
Associated Topics
TCOMMIT Command
TRESTART Command
TROLLBACK Command
TSTART Command
$TRESTART Special Variable
Examples
W $TLEVEL
4
This example writes the number of TSTART commands processed since the last TCOMMIT
or transaction restart.
Syntax
$TR{ESTART}
Definition
The $TRESTART special variable contains a count of the number of transaction
restarts that have occurred during the transaction. The restarts can be explicit (a
TRESTART command) or implicit (a system-initiated restart). A value of 0 indicates
that no restarts have occurred. Any other positive value indicates restarts have
occurred. This variable is initialized to 0 when the job (process) is started. It is also
set to 0 by the successful completion of the TCOMMIT or TROLLBACK command.
During the transaction, each transaction restart adds one to the value of the
$TRESTART variable.
Associated Topics
TCOMMIT Command
TRESTART Command
TROLLBACK Command
TSTART Command
$TLEVEL Special Variable
Examples
W $TRESTART
3
This example writes the number of transaction restarts that have occurred during the
transaction.
Syntax
$X
Definition
The $X special variable is used to keep track of the X-coordinate of the last character
output to the current device. The values may range from 0 to 255. Whenever a
carriage return (the ! format character, the # format character, $C(13), or *13) is
encountered, the value of $X is reset to 0. In addition, when the value is incremented
beyond 255, it is reset to 0. The ?Val format sequence (horizontal tab) sets $X to the
specified tab location (Val) if it is greater than the current value of $X. Otherwise,
the value of $X remains unchanged. The value of $X may be changed by the user
with a SET command.
Associated Topics
Format Characters
Examples
W !,"123" S Y=$X
W # S Y=$X
W:$X>72 !
This code writes a carriage return and then line feeds if $X indicates that the next output
character would be to the right of column 72.
S $X=27
Syntax
$Y
Definition
The $Y special variable is used to keep track of the Y-coordinate of the last character
output to the current device. The values may range from 0 to 255. Whenever a line
feed (the ! format character, $C(10), or *10) is encountered, the value of $Y is
incremented by one ($Y=$Y+1). On form-feed characters (the # format character,
$C(12), or *12), the value of $Y is reset to 0. In addition, when the value is
incremented beyond 255, it is reset to 0. The value of $Y may be changed by the user
with a SET command.
Associated Topics
Format Characters
Examples
W # S Y=$Y
W #!!! S Y=$Y
W:$Y>56 #
This code writes a form feed, which includes a carriage return, if $Y indicates that the next
output character would be below row 56 of the page.
S $Y=31
Syntax
$ZA
Definition
The $ZA special variable contains an integer value that relates to error conditions,
status indicators, and so on, for the current device.
Associated Topics
OPEN Command
USE Command
Examples
U 51 R X S RC=$ZA RC=$ZA
The HFS device is made the current device, and one record is read from the device. The status
information associated with the READ operation is saved in the RC local variable.
Syntax
$ZB
Definition
The $ZB special variable contains an integer value that relates to error conditions,
status indicators, and so on, for the current device.
Associated Topics
OPEN Command
USE Command
Examples
U 51 R X S RC=$ZB
The HFS device is made the current device, and one record is read from the device. The status
information associated with the READ operation is saved in the RC local variable.
Syntax
$ZC
Definition
The $ZC special variable contains an integer value that relates to error conditions,
status indicators, and so on, for the current device. In general, a non-zero value
indicates an error condition.
Associated Topics
OPEN Command
USE Command
Examples
U 51 R X S RC=$ZC
The HFS device is made the current device, and one record is read from the device. The status
information associated with the READ operation is saved in the RC local variable.
Syntax
$ZE{RROR}
Definition
The $ZERROR special variable contains the error message most recently issued by
the MSM system. The message is in the format of <ErrMsg> Detail. The ErrMsg
portion is a five-character abbreviation for the error, and Detail is the detailed
information about the error.
This variable is most commonly used in conjunction with the $ZTRAP variable to
determine what type of condition caused the error trap to be entered. For additional
information on error trapping and error messages, refer to the $ZTRAP special
variable, and to Appendix B, "Error Processing" in this document.
Associated Topics
$ECODE Special Variable
$ETRAP Special Variable
$ZTRAP Special Variable
Appendix B, Error Processing
Examples
W $ZE
<UNDEF>+17^CUSINQ:::4:1
This example writes out the current value of the $ZE variable. In this case, it indicates an
<UNDEF> error in the CUSINQ routine (the 4:1 indicates that a reference was made to an
undefined global).
Syntax
$ZL{EVEL}
Definition
The $ZLEVEL special variable contains a value that indicates the current nesting
level. The value is initialized to 0 when the partition is created, and it is incremented
each time a DO, FOR, or XECUTE command is processed. Each time an implicit or
explicit QUIT command is processed, the value is decremented.
Note that the initial value of the variable can be different depending on the mode in
which the user is operating and how the routine was entered. For example, when
operating in direct mode, this variable has an initial value of 1. When the routine that
is executing is entered as a result of a tied-terminal entry, this variable has an initial
value of 2.
Associated Topics
DO Command
FOR Command
QUIT Command
XECUTE Command
Using the MSM System, MSM User's Guide
Configuring the System, MSM User's Guide
Examples
W $ZLEVEL
4
This example writes the number associated with the current nesting level.
Syntax
$ZN{AME}
Definition
The $ZNAME special variable contains the name of the routine that is currently
loaded into the partition. The $ZNAME variable is equivalent to $TEXT(+0). If the
routine currently loaded into the partition is unnamed or if there is no routine loaded
into the partition, then $ZNAME contains a null value.
Associated Topics
DO Command
$TEXT Function
ZLOAD Command
ZREMOVE Command
Examples
W $ZN
TESTPGM
This example writes the name of the routine that is currently loaded into the partition.
ZR W $ZN
Syntax
$ZO{RDER}
Definition
The system maintains the fully qualified name (UCI, volume group, global name, and
subscripts) of the last global referenced in the $ZREFERENCE special variable. The
$ZORDER special variable returns the data value of the next global node that follows
this last global reference in collating sequence. Accessing the $ZORDER variable is
equivalent to the following statement:
S DATA=@($ZORDER(@$ZREFERENCE))
In the case where the last global reference is to the last defined node of a global, then
the above reference results in an <UNDEF> error.
Associated Topics
$NEXT Function
$ORDER Function
$ZREFERENCE Special Variable
Examples
S ^X(1,1)=1,^X(1,2)=2,^X(1,3)=3
S X=^X(1,2)
W $ZORDER
This example writes the data value 3 (the data value of the node that follows the last global
reference that was made).
Syntax
$ZR{EFERENCE}
Definition
The $ZREFERENCE special variable contains the full global name (the global name
and the subscripts) of the last global referenced or the extended global name (the UCI
name and the volume group name in brackets followed by the global name and
subscripts) if the global referenced is in a different UCI or in a different volume
group. For additional information on referencing globals in a different UCI or
volume group, refer to the MSM User's Guide.
Associated Topics
Global Variables
Examples
S ^CUS(1,2,3)="JONES^JOHN" W $ZR
^CUS(1,2,3)
This example first sets a node in the CUS global and then writes out the value of $ZR. The
global reference for the node that was accessed is displayed.
S ^|"PRD","VGA"|CUS(1,2,3)="JONES^JOHN" W $ZR
^|"PRD,VGA"|CUS(1,2,3)
This example first sets a node in the CUS global in the PRD UCI on the VGA volume group
and then writes out the value of $ZR. The global reference for the accessed node is displayed,
including UCI and volume group name.
Syntax
$ZT{RAP}
Definition
The $ZTRAP special variable is used to set a trap that is invoked when an error
condition occurs. The trap can be specified as a line label (ERROR), a routine name
(^%ET), or a line label and routine name (ERR^MYPROG). Whenever an error
occurs, execution automatically returns from any nested DO or XECUTE commands
(which have not specified any error handling) and then a GOTO command is issued
with the $ZTRAP variable as the argument. Indirection may be used in the trap
specification.
Upon entry to the trap routine, the $ZTRAP special variable is set to the empty
string, the $ZERROR special variable contains information about the error; and
$ECODE is set to the empty string. Refer to the MSM User's Guide for additional
information on trapping errors.
Considerations
When the error trap routine or label is invoked, the $ZTRAP variable is set to null. It
is the responsibility of the error trap routine to re-establish the trap if appropriate.
One $ZTRAP special variable can be set at each execution level. This means that
each execution level in an application can establish its own error trapping routine and
error recovery procedures.
Setting $ZTRAP also performs the following action:
NEW $ETRAP SET $ETRAP=""
This is done to ensure that either $ZTRAP or $ETRAP, but not both, is used to trap
the error condition.
Examples
S $ZTRAP="^%ET"
S $ZT="ERR^MYPROG"
This example passes control to the ERR label of the MYPROG routine if an error is
encountered.
S $ZT=""
Syntax
$ZV{ERSION}
Definition
The $ZVERSION special variable contains the name of the MSM system being used
(for example, MSM-PC/PLUS, MSM-UNIX, MSM for Windows NT) and the
release number of the software (for example, Version 4.3.0).
Considerations
The $ZVERSION variable can be used to test the system type if the software
contains implementation-specific or release-specific features of MSM.
Examples
W $ZV
This example prints the name and version number of the MSM system that is in use.
Overview
This chapter describes the ANSI-standard M structured system variables (SSVNs),
and the additional vendor-specific structured system variables that exist in the MSM
implementation of M.
The M language includes a number of structured system variables that are maintained
by MSM and can be accessed by the programmer. The SSVNs are designed to
provide information on various system resources. After these variables are examined
by a program, decisions can be made within the program based on their values.
In MSM, all of the ANSI-standard structured system variables are provided, as are an
extended set of structured system variables specific to MSM. The ANSI-standard
structured system variables begin with ^$ (^ followed by a dollar sign) followed by
the letters A through Y. No MSM-specific SSVNs currently are defined. SSVNs can
be abbreviated or fully spelled out, and SSVN names can be specified in uppercase,
lowercase, or a combination of uppercase and lowercase alpha characters. For
example, all of the following are equivalent and valid abbreviations.
^$ROUTINE
^$routine
^$R
^$r
The following sections describe the structured system variables provided in the MSM
system, including syntax, a description of the value, special considerations,
associated topics, and examples. For additional information about writing M
programs, refer to the MSM User's Guide.
MSM Language Reference Manual Chapter 7 MSM Structured System Variables • 257
^$DEVICE
Provides information on the existence, operational characteristics, and availability of
a device.
Syntax
^$D{EVICE}(DeviceNum)
Definition
DeviceNum An expression that evaluates to a device number.
The $DEVICE structured system variable provides information on the existence,
operational characteristics, and availability of a specified device. If the device exists,
$DATA of the ^$DEVICE variable returns a value of 10. Otherwise, $DATA returns
a value of 0.
Defined Nodes
None
Associated Topics
Using Peripheral Devices, MSM User's Guide
Examples
$DATA(^$DEVICE(3))
$ORDER(^$D(3))
This expression returns the device number of the next device defined in the system after
device number 3.
258 • Chapter 7 MSM Structured System Variables MSM Language Reference Manual
^$GLOBAL
Provides information on the existence, operational characteristics, and availability of
a global.
Syntax
^$G{LOBAL}(GlobalVar)
Definition
GlobalVar An expression that evaluates to a global variable name.
The $GLOBAL structured system variable provides information on the existence,
operational characteristics, and availability of a specified global. If the global exists,
$DATA of the ^$GLOBAL structured system variable returns a value of 10.
Otherwise, $DATA returns a value of 0.
Defined Nodes
None
Associated Topics
Global Variables
Examples
$DATA(^$GLOBAL("^A"))
This expression tests for the existence of global ^A (existence is defined as $D(^Global)>0).
$ORDER(^$G("^A"))
This expression returns the name of the global that follows the global named A in the global
directory.
SET X=""
FOR S X=$0(^$G(X)) Q:X="" WRITE !,X
This code loops through the entire global directory, writing each global name to the current
device.
MSM Language Reference Manual Chapter 7 MSM Structured System Variables • 259
^$JOB
Provides information on the existence and operational characteristics of a process.
Syntax
^$J{OB}(JobNum)
Definition
JobNum An expression that evaluates to a job number.
The $JOB structured system variable provides information on the existence and
operational characteristics of a specified job. If the specified job is active, $DATA
of the ^$JOB structured system variable returns a value of 10. Otherwise, $DATA
returns a value of 0.
Defined Nodes
None
Associated Topics
JOB Command
Examples
$DATA(^$JOB(16))
$ORDER(^$J(16))
This expression returns the job number of the next job that is active in the system after job
number 16.
260 • Chapter 7 MSM Structured System Variables MSM Language Reference Manual
^$LOCK
Provides information on the existence and operational characteristics of a locked
resource.
Syntax
^$L{OCK}(Variable)
Definition
Variable An expression that evaluates to a local or a global variable name.
The $LOCK structured system variable provides information on the existence and
operational characteristics of a specified locked resource. If the specified resource
has been successfully LOCKed (and not yet unLOCKed), $DATA of the ^$LOCK
structured system variable returns a value of 10. Otherwise, $DATA returns a value
of 0.
Defined Nodes
None
Associated Topics
LOCK Command
ZALLOCATE Command
ZDEALLOCATE Command
Examples
$DATA(^$LOCK("^A"))
$ORDER(^$L("^A"))
This expression returns the name of the next resource that is locked.
$ORDER(^$L("^A"))
SET X=""
FOR S X=$0(^$L(X)) Q:X="" WRITE !,X
This code writes the entire contents of the lock table to the current device.
MSM Language Reference Manual Chapter 7 MSM Structured System Variables • 261
^$ROUTINE
Provides information on the existence, operational characteristics, and availability of
a routine.
Syntax
^$R{OUTINE}(RoutineName)
Definition
RoutineName An expression that evaluates to a routine name.
The $ROUTINE structured system variable provides information on the existence,
operational characteristics, and availability of a specified routine. If the routine
exists, $DATA of the ^$ROUTINE structured system variable returns a value of 10.
Otherwise, $DATA returns a value of 0.
Defined Nodes
zsdate Returns the $HOROLOG date/time at which the routine was last
ZSAVEd.
Associated Topics
Global Variables
ZSAVE Command
$HOROLOG Special Variable
$ZDATE Function
Examples
$DATA(^$ROUTINE("A"))
$ORDER(^$R("A"))
This expression returns the name of the routine that follows the routine named A in the routine
directory.
WRITE $ZDATE(^$R(“A”,”zsdate”))
262 • Chapter 7 MSM Structured System Variables MSM Language Reference Manual
Appendix A ASCII Collating
Sequence
Overview
This appendix provides a list of the ASCII collating sequence values.
Overview
This appendix describes methods of trapping errors during program execution, and
lists error messages that may be generated during execution.
The second line handles the case in which the $ETRAP code completes and
execution then continues on the second line. The QUIT commands are set up so that
the current execution level terminates correctly depending on whether or not it was
invoked as an extrinsic.
If $ZTRAP is non-null, MSM internally performs the following line of M code:
SET $ECODE="" GOTO @($ZTRAP)
As part of the GOTO, the value of $ZTRAP is reset to the null string. If additional
error handling is required at the current execution level, $ZTRAP must be
reestablished. The value of $ECODE is cleared to ensure that when the current
execution level terminates, $ECODE is null. Otherwise, a return to an execution level
where $STACK($STACK,"ECODE")) is null and $ECODE is not null would
generate an error (in accordance with the 1994 ANSI M standard). Because $ZTRAP
code presumably was written prior to the 1994 ANSI standard, it is not likely to
contain code that explicitly resets $ECODE. To maintain compatibility with existing
applications, MSM clears $ECODE prior to transferring to the $ZTRAP error
handling code.
MSM terminates the current execution level. This includes restoring values stacked
by the NEW command (possibly including $ESTACK and $ETRAP).
MSM terminates any active FOR loops and indirections in the current execution line.
MSM continues with step 1 above until an execution level is reached that does
specify error handling via $ETRAP or $ZTRAP.
To ensure that error handling is uniquely defined, MSM does not allow both
$ETRAP and $ZTRAP to be non-null at the same time. When $ETRAP is
established via the SET command, MSM internally resets $ZTRAP to the empty
string. When $ZTRAP is established via the SET command, MSM internally
performs a NEW command on $ETRAP and then sets its current value to the empty
string (a QUIT from this execution level restores $ETRAP to its original value). This
interaction between $ETRAP and $ZTRAP allows existing applications that rely on
$ZTRAP to coexist (on the execution stack) with applications that rely on the ANSI
standard method of error trapping.
Refer to Chapter 5, “MSM Functions,” and Chapter 6, “Special Variables,” in this
document for additional information.
When an error is detected, MSM sets locals X and Y to the current values of $X and
$Y respectively, and then transfers control to the first line in routine ^ERROR. This
routine can attempt to recover from the error, record the error and any application-
specific information, or allow the error to propagate to the previous execution level
where it can be handled, recorded, or continue to be propagated to earlier execution
levels. If the error processing routine does not clear $ECODE before exiting from the
execution level where an error occurred, error processing is still in effect in the new
execution level. A common use for M error handling features is to NEW $ESTACK
at the top menu level of the application and to continue in error processing mode
until the $ESTACK returns to zero.
When an error is detected, MSM terminates execution levels one at a time until it
reaches an execution level at which $ZTRAP is not null. MSM then performs a
GOTO to the entry point contained in $ZTRAP and also resets $ZTRAP to the empty
string. This routine can attempt to recover from the error, record the error and any
application-specific information, or force the error to be propagated to an earlier
execution level that has a non-null $ZTRAP where the error can be handled,
recorded, or continue to be propagated to earlier execution levels. Because MSM
internally resets the $ZTRAP used to invoke the error handling routine, $ZTRAP
must be explicitly SET to a new non-null value if additional errors are to be trapped
at the current execution level.
B ;Routine B
...
;NO $ZTRAP SET
...
DO ^C
...
...
%ET
When an error occurs and this utility is invoked, the routine stores the values of the
$ZERROR, $HOROLOG, $JOB, $IO, and $STORAGE special variables; the key of
the last global referenced ($ZREFERENCE); and the contents of the local symbol
table. It also writes a message to the principal device indicating that a program error
was encountered and displays the contents of the $ZERROR special variable.
%ER
This utility reports errors that were trapped using the %ET routine. It allows the user
to display, print, delete, or summarize errors. As a powerful programming and
debugging tool, the %ER utility allows the programmer to reload the local symbol
table with the local variable values that existed when the error occurred. After
loading the variables, the routine exits and returns the user to programmer mode.
Interactive Debugging
An MSM facility allows users operating in programmer mode to interactively step
through execution of a program either one line or one command at a time. This
facility also includes the ability to set breakpoints in programs without modifying the
source code for the routine, and to display and alter the contents of local variables.
This feature is most commonly used by the programmer to more efficiently trace
error conditions and determine the cause of an error. The interactive debugger is
invoked by entering the following command at the M programmer prompt.
DO ^%DEBUG
The system responds with a menu of options. The utility program includes complete
online help information and is easy to use.
Format of $ZERROR
The $ZERROR special variable contains descriptive information about the most
recent error. This information is also provided as a piece of the $ECODE special
variable when the $ETRAP mechanism of error trapping is used. The format of this
descriptive information is as follows.
<Code>Offset^RoutName:Cmnd:Arg:Major:Minor:AddInfo
Code Explanation
<ASYNC> An error occurred during the asynchronous processing of a previous SET
or KILL operation on a remote volume group. This error is suppressed
unless it is specifically allowed by a mode flag set through the SYSGEN or
%MODESET utilities. The type of error is indicated in the additional
information field of $ZERROR. This number is formed by
major*256*+minor.
<BADCH> An invalid character was encountered.
<BKERR> The interpreter encountered a BREAK command while executing a
program. The BREAK command is used primarily for program debugging
and allows the user to inspect the program, local variables, and global
variables at a specified location within the program. Program execution can
be resumed using the ZGO command.
<CLOBR> An attempt was made to overlay the current routine by issuing a ZLOAD,
ZREMOVE, or ZINSERT command from within the routine.
<CMMND> The interpreter encountered an illegal or undefined command.
<DDPER> A Distributed Data Processing (DDP) error occurred.
<DIVER> An attempt was made to divide a number by zero.
<DKFUL> No space is available on the disk within the expansion limits of the current
UCI. Information that the system was trying to write to the disk was lost.
Database corruption can result.
<DKHER> The MSM system encountered an unrecoverable error while trying to read
from or write to a disk-type device. This is caused by a hardware
malfunction or an attempt to reference a block that is outside the physical
bounds of the disk.
<DKRES> An attempt was made to allocate a block in the reserved area at the end of
the user’s expansion area because the expansion area is nearly full. If the
AddInfo field in $ZERROR is 0, the operation was suppressed; if 1, the
operation was completed.
<DKSER> A block read in from the disk was not the type expected by the system or
the block’s internal structure was invalid. This can occur if the database is
corrupted by a hard system failure such as a power failure, or a hardware
malfunction such as an unrecoverable disk error on a write operation.
<DPARM> Invalid use of parameter passing.
<DSCON> The current device has been disconnected from the system.
<DSTDB> A network communications link failed during a Distributed Data
Processing (DDP) data transfer.
<ECODE> An attempt was made to set $ECODE to an invalid value, or error
processing was initiated by changing $ECODE from null to a valid value.
<EXPER> An exponentiation error was detected.
<FUNCT> The interpreter encountered an undefined function or a function that was
used improperly.
<INDER> The interpreter encountered illegal or incorrect use of the indirection
operator.
(&2'( (UURUV
Overview
MSM's mnemonic namespaces feature allows users to develop M applications that
are relatively device independent in handling low-level device functions (for
example, clearing a terminal screen or backspacing one block on a tape). Mnemonic
namespaces can be used to access many of the device types supported by MSM.
The device types that can be supported through namespaces include: terminal
devices, sequential block processor (SBP) devices, host file server (HFS) devices,
interjob communication (IJC) devices, magnetic tape devices, the MSM spool device,
and the host system spool device. For additional information about mnemonic
namespaces, refer to Chapter 4, "MSM Commands", in this document, and Chapter
7, "Using Peripheral Devices," in the MSM User's Guide.
Two types of mnemonic namespaces are supported in MSM: built-in namespaces and
user-defined namespaces. MSM's standard distribution includes two built-in
namespaces and one user-defined namespace. The X3.64-1979 built-in namespace is
commonly referred to as the ANSI terminal namespace. The ZWINTERM built-in
namespace allows windowing capabilities on dumb terminals.
The user-defined namespace is called X3.64 TEMPLATE and is distributed in a
DOS file called ANSI.NAM. The system manager can use this namespace as a
template to create other namespaces. The X3.64 TEMPLATE namespace can be
imported into the MSM database using the Import a Namespace option. The template
then can be copied to a new name and edited. It includes the complete set of ANSI
mnemonics.
Because ANSI terminals are the most frequently used terminal type in M
applications, the namespace for this terminal type was directly built into the system.
From a technical point of view, a built-in namespace is coded directly into the MSM
system monitor rather than through user-supplied M code. As a result, overhead when
using this namespace is significantly reduced.
Because the X3.64-1979 is built-in, it cannot be edited or deleted by the user. The
mnemonics defined within the namespace cannot be listed through this option of the
SYSGEN utility.
Attributes
The ZWINTERM mnemonic namespace supports attributes for setting text attributes
(bold, blink, underline, reverse) and colors (background and foreground) within a
window, within a border, and within a title. The following table describes the
supported attributes.
Attribute Description
0 Restores normal text attributes
1 Sets bold attribute for text
2 Sets underline attribute for text
5 Sets blink attribute for text
7 Sets reverse video attribute for text
22 Clears bold attribute for text
24 Clears underline attribute for text
25 Clears blink attribute for text
27 Clears reverse video attribute for text
30 Sets foreground color to black
31 Sets foreground color to red
32 Sets foreground color to green
33 Sets foreground color to yellow
34 Sets foreground color to blue
35 Sets foreground color to magenta
The attribute values can be specified on the /SGR, /WBSGR, /WTSGR, /WDSGR,
and /WCSGR functions. In addition, multiple attributes can be specified for a
character location.
For example, the background color can be set to cyan, the foreground color to white,
and the foreground text to blink. This is done by issuing multiple ZWINTERM
control mnemonics that address the same character location. The following example
illustrates how this is done.
W /CUP(10,40),/SGR(46),/SGR(37),/SGR(5)
All of the text attributes can be reset with a single operation by specifying a 0
attribute value. The background and foreground colors are not affected by a 0
attribute value, and the colors must be explicitly changed.
Erase Operations
The ZWINTERM mnemonic namespace supports several types of erase operations
within a window. These erase operations are specified as an operand on several of the
ZWINTERM control mnemonics. The following table describes the supported erase
operations.
=:,17(50 (UDVH $WWULEXWHV
The erase values can be specified on the /ED, /EL, /WCMD, and /WCML control
mnemonics. The /ED and /EL functions clear the memory buffer and the screen. The
/WCMD and /WCML functions only clear the memory buffer. If desired, the /WDSP
function can be used after these functions to refresh the screen with the contents of
the memory buffer. When multiple updates to a screen are required, the program can
use functions that only update the memory buffer followed by a refresh. This
approach prevents unnecessary repaints of the screen and improves performance.
/CUR(Display) - Cursor
Display An integer value from 0 to 4 that indicates actions to be performed on the
cursor within the window. If this value is invalid or omitted, a value of 0 is
assumed.
0 Shows cursor
1 Hides cursor
2 Saves cursor and attributes
3 Restores cursor and attributes
4 Forces cursor and attributes
This function is used to perform cursor actions within the current window. It allows
the programmer to show or hide the cursor, save the cursor location and attributes,
and restore the cursor location and attributes.
In this example, two parameters are passed to the CUP mnemonic. The first
parameter, 10, is contained in the $1 variable and the second parameter, 55, is
contained in the $2 variable. The $0 variable contains 2 to indicate that two
parameters were passed. In this example, the following M code is associated with the
CUP mnemonic.
W *27,$C($1+31),$C($2+31) S $Y=$1,$X=$2
The WRITE command in this example outputs the actual escape sequence required
by the terminal to position the cursor. The SET command updates the values of $X
and $Y to match the new cursor position. Refer to Chapter 6, "MSM Special
Variables," in this document for additional information on the $X and $Y special
variables.
Select Option:
Select Option:
W *27,"[",$1,";",$2,"H" S $Y=$1,$X=$2
Select Option:
Enter the name of the Mnemonic Namespace to be copied. The name you
choose must be defined, but cannot be a built-in Namespace.
Enter '^L' for list of currently defined Namespaces.
.....! done.
Select Option:
Select Option:
Deleting........done.
Select Option:
.....! done.
Select Option:
Export Namespaces
This option is used to save a user-defined namespace to an external file so that it can
be copied to another system. When this option is selected, the user is prompted for an
output device in a dialogue similar to the one used by the %GS (Global Save) Utility.
The user is prompted to select the namespaces to be exported. The following sample
terminal session illustrates the Export function.
Select Option: 7 - Export Namespaces
Saving ...
^SYS
^SYS
Save complete.
Restoring...
Mnemonic Namespace: X3.64 TEMPLATE ... Restored
Restore Complete
Overview
This appendix describes how to write user-defined commands, functions, and special
variables in MSM.
Examples
The following examples illustrate, in sequence, a user-defined command, function,
and special variable.
%ZZCMNDS ;User-Defined Commands
;
SHELL ;Syntax: ZZSHELL with no operands
ZT:$0>0 "SHELL"
N X
I $ZV["PC" S X=$$TERMINAL^%HOSTCMD("COMMAND") Q
I $ZV["UNIX" S X=$$TERMINAL^%HOSTCMD("sh") Q
I $ZV["VX" S X=$$TERMINAL^%HOSTCMD("spawn") Q
Overview
The MSM development environment provides a preprocessor that compiles
source-code documents, called sources, to produce standard executable M-code
routines.
The preprocessor is controlled by preprocessor directives embedded in the source
document, and replaces macro symbolic names with text from the macro definitions.
The preprocessor is invoked automatically when a source is saved using the %G
editor or MSM-Workstation for Windows editor, restored from a host file, or copied
between UCIs. Comprehensive cross-references may be maintained to track where
names and source files are defined and used.
Source preprocessing can be used for the following:
• Definition of simple macros as constants or expressions.
• Definition of parameterized macros for more powerful capabilities.
• Definition of libraries of macros.
• Macro expansion.
• Source file inclusion.
• Conditional inclusion of source code lines.
Keyword
A keyword is a macro that expands to multiple lines of code. Because of its multiple-
line definition, it has an alternative syntax and restrictions and is given its own
conceptual category. However, it is essentially a multi-line macro.
Library
A library is a pre-constructed collection of macro definitions that can be incorporated
together into a source code file by using a single directive. Directives that are related
to libraries are described in "Advanced Capabilities" in this appendix.
Macro
A macro is a symbolic name for a string of text. The macro definition defines the
symbolic name and its associated text string. The macro reference refers to the
symbolic name, which the preprocessor replaces with a definition string.
Parameterized macros allow substrings in the definition string to be substituted with
corresponding arguments.
Source
A source is a M routine or other document stored in a global.
Syntax
The elements of preprocessor syntax include macro names, special prefixes, case, and
parameter names.
Macro Names
Macro names are composed of one or more alphanumeric characters.
Special Prefixes
Macro names are referenced by using a special introducer prefix that has a default
value of %%. For example, a macro named Maximum is used by placing
%%Maximum in M code. If parameterized, the string of actual arguments is
parenthesized and passed positionally.
Preprocessor directives are recognized by the presence of the directive prefix as the
first non-blank character of a line. This prefix is the character # (pound sign or hash
sign). The primary preprocessor command, #define, is used to define macros.
Keywords can be referenced by using an alternative keyword prefix of #%. If
parameterized, the string of actual arguments is passed after a single space in a
comma-delimited list, without using parentheses.
Parameter Names
Parameterized macros are indicated by following the macro name in the #define with
(parameter list). If the list is empty, formal names $1, $2, ... are used. Alternatively,
the list can have any alphanumeric names, if meaningful names are desired.
Defining a Macro
A macro is defined by placing a line with the following syntax in the source file:
#define MacroName Definition
For example:
#define MDC Micronetics Design Corporation
A macro can be parameterized, using $1, $2, ... as the arguments' formal names:
#define copyright() Copyright %%MDC $1
Referencing a Macro
Macros are referenced by using their name in a line of code, prefixed by the macro
introducer string, which has a default value of %%. For example, the definition of
%%copyright in "Defining a Macro" above can be used in the following:
W "Program ABC %%copyright(1995,1996)."
Most simple macros can appear in the middle of a line, surrounded by other code.
However, macros that expand to multiple lines of code cannot appear in the middle
of a line (for example, within the scope of a single-line If or For command; if they are
used in this way, a comment is placed in the generated routine to indicate an error).
Macros on lines within block-structured subroutines retain the specified execution
level (as indicated by leading dots), as do all generated lines if the macro expands to
multiple lines.
and
#%copyright 1995,1996
The #% prefix is intended for use with macros which expand to multiple lines. The
syntax is a reminder that such a multi-line macro should not be embedded in another
line, though there are also other safeguards which prevent this error. Use of the #%
syntax is a matter of preference; the %% prefix may be used everywhere.
Using Parameters
The number of actual parameters present when a macro is expanded is provided in
$0. The default names for parameters are $1, $2, and so on, although alphanumeric
names can be used.
If alphanumeric names are used for formal parameters, the names must not conflict
with real variable names that might be passed as parameters. The use of a naming
convention prevents such conflicts.
The formal list can specify fewer parameters than in the definition, or none at all.
However, the macro definition must have at least (); without the parentheses, a macro
that takes no arguments is defined.
Arguments without formal names that are passed during macro use are assigned
names in the $n form.
When a macro is used, if more actual arguments are specified than are used in the
definition, the macro expansion generates an error in comment form.
Including a File
The #include directive is used to include a source file in another file. The following
example illustrates how to include common subroutines called UTILITY in another
routine.
#include UTILITY
Frequently, common definitions or libraries for a package are combined into a header
file. For example:
#include BLD.HDR
Although naming conventions can be used (for example, .HDR for headers, .LIB for
libraries, .INC for include), they are arbitrary and are not required.
Generated Comment
The preprocessor inserts a comment line as the second line of generated routines. The
following format is used:
;;GENERATED from <serial#> <uci> <sourcename> <version#> <date> <time>
For example:
;;GENERATED from 1111494 DEV,WDD Test v1 23Mar95 9:49pm
Libraries
Libraries are used to store macro definitions.
Defining Libraries
The #makelib directive (re-)initializes a library.
A library is defined to create a group of macro definitions that are used together in
several places and to avoid the small overhead of compiling macro definitions. After
creation of a source document that contains a #makelib directive and a library name,
any number of macro definitions can be placed in the library.
#makelib Standard
#define ...
Macro definitions are stored in a global other than the default global, ^ZMSMMAC,
by including an additional argument, as illustrated in the following example.
#makelib Standard ^MYMACS(1)
When defining a library, the intention is to define macros, not to generate a routine.
A #noroutine directive appears at the top of a source which is a library definition.
See the section on #noroutine in "Preprocessor Directives".
Updating Libraries
The #updlib directive appends to an existing library. If no library exists, #updlib
creates a library.
A single library can include groups of macros from different source files by using
#updlib. For example, the following line appears at the top of a source that augments
the Standard library.
#updlib Standard
Using Libraries
The #library command incorporates one or more libraries of macro definitions for
use in a program.
A #library command, followed by the name(s) of one or more libraries, specifies the
search path that is used to find macro definitions. The order of the names is
significant because it defines the order of the search.
#library Custom,Standard
A pre-existing path is modified by placing new library names at the beginning or end
of the path. A name followed by + (plus sign) is placed at the front of the path; a +
followed by a name places the name at the end of the path. The following example
illustrates the #library Custom,Standard path.
After #library MyOwn+, the search path is "MyOwn,Custom,Standard."
After #library +TheEnd, the search path is "MyOwn,Custom,Standard,TheEnd."
Macros that are defined in the source or in #include files take precedence over library
macros of the same name.
Conditional Compilation
The #if, #ifdef, and #ifndef directives and the associated #elseif, #else, and #endif
directives are used to include code conditionally in the generated routine. As the
following example illustrates, debugging code is removed from a routine by
commenting out the #define line.
#define Debug 1
#ifdef Debug
w "Debugging..." d ^Whatever
#endif
...
The #if blocks can be nested. Indentation of lines is used to clarify the blocks.
Special Macros
Array Macros
The #defarray variant of the #define directive is used to define arrays. For example:
#defarray tmp ^XSCRATCH($J)
Null Macro
Expressions can be evaluated at pre-processing time with the built-in null macro,
whose name is identical to the current macro introducer prefix (by default, %%). For
example, if the following definitions are present:
#define Green 2
#define Blue 4
#define Cyan1 %%Green+%%Blue
#define Cyan2 %%(%%Green+%%Blue)
Then:
%%Cyan1 generates 2+4
%%Cyan2 generates 6
%%(%%Cyan1) generates 6
ZMsmPreviousLabel
This macro expands to the label that precedes the current line. For example, if a
routine contains the following:
FUNCA ;
...
S $ZE="q%%ZMsmPreviousLabel^"_$T(+0)
ZMsmTimestamp
This macro expands to a timestamp like the first line timestamp. For example:
W "Routine filed at %%ZMsmTimestamp"
Empty Lists
A macro can be defined as having parameters, even if it has not been given
parameters. Such a macro can be used to construct names because the empty "(" that
begins the empty argument list signals the macro's end.
For example, to assign one prefix to a group of names while allowing the prefix to be
easily changed, a parameterized macro is defined for the prefix.
#define prefix() ^%App
#define nam %%prefix()nam
#define id %%prefix()id
D %%nam,%%id generates D ^%Appnam,^%Appid
This system can be built entirely with non-% names by removing the % from the
definition of %%prefix.
The same process can be used to build variables with unique names. For example, in
routines that must deal with by-reference arguments (which refer to variables that
potentially have any name), variable names that are unlikely to collide can be
defined.
#define junk() xYzZy
#define from %%junk()1
#define to %%junk()2
S (%%from,%%to)="" generates S (xYzZy1,xYzZy2)=""
Multi-Line Definitions
A multi-line macro definition is bracketed by #define and #enddef directives.
#define MultiLiner
w "line 1"
w "line 2"
#enddef
Computed Definitions
A program can be used to build arbitrarily complex macro definitions. The program
is invoked with the null macro, and the result is returned in variable Val. For
example:
#define Do(win,parms:"") %%(D Do^UTL(win,parms))
UTL ;
Do(w,p) ; compute macro
...
S Val="whatever"
Q
If the default value "" for parameters is not included and if parameters are omitted in
a 1-argument call, a syntax error results from D Do^UTL(win,). If the default value is
used, such an error is impossible.
System Functions
The following functions are defined in the macro preprocessor and can be used by
macros that compute their own definitions.
Function Description
DEFINED(Name) Returns True if macro Name is defined.
SS(X) Strips leading spaces.*
STS(X) Strips trailing spaces.*
QQ(X) Quotes—double-up quotes.*
HQ(X) Halves quotes.*
The prefix in force is the prefix that is used to find macro references. If the prefix is
changed, macros that use the previous prefix are not seen as macros and do not
expand. This capability can be used by program generators to generate programs
containing macros that are expanded only after the programs are constructed.
The default prefix can be reset using the directive as follows:
#prefix
#comment
Turns on the insertion of pre-expansion lines of code that contain macros into the
generated code as comments.
Syntax
#comment [all]
Definition
The comments are placed at execution level 10 (the lines have 10 leading dots) to
avoid terminating structured subroutine blocks and . Lines that sequentially follow
the #comment are treated in this manner.
The #comment all form shows all intermediate expansions. Without the "all" only the
initial pre-expansion form is shown.
#defarray
Defines a macro to be used for referencing an array.
Syntax
#defarray MacroName Definition
Definition
Parameter Description
MacroName An alphanumeric name beginning with an alpha, with no
parameters.
Definition The macro definition, a global or local variable name.
This directive defines a name to be used for constructing array references. The macro
expansion depends on the context. When the macro is used, if the name is
immediately followed by a "(", an array reference is constructed by adding the
subscripts following the "(" to those (if any) in the Definition.
The directive may be abbreviated as #defarr.
Syntax
#define MacroName[ParmList] Definition
or
#define MacroName[ParmList] [/Switch]...
Definition
...
#enddef
Definition
Parameter Definition
MacroName An alphanumeric name that begins with an alphabetic character; any
reasonable length can be used.
ParmList ([Parm,...]) where Parm is an optional formal name for a parameter.
Definition The macro definition; requires #endef form if null or multi-line.
Switch One of the defined switches:
/EMBED allows embedding of a multi-line definition.
Syntax
#deflabel LabelName[,...]
Definition
Parameter Definition
LabelName A valid macro name.
Syntax
#if Condition
Code
#elseif Condition
Code
#else
Code
#endif
Definition
Condition A valid M expression.
Code Valid M code.
During preprocessing, sections of code can be conditionally included or ignored. The
#if...#endif pair brackets code that is included only if Condition is true. For example,
a variable that is set by an earlier #x command can be tested by an #if. Multiple
alternatives are included by using multiple #elseifs, and a catch-all condition is
included by using #else. Conditions can be nested.
Syntax
#ifdef MacroName
or
#ifndef MacroName
Code
#else
Code
#endif
Definition
Parameter Description
MacroName A valid M expression.
Code Valid M code.
#include
Includes source code; redirects input stream.
Syntax
#include FileName
Definition
Parameter Description
FileName The name of a file.
During preprocessing, a selected file is scanned and processed. A file can include
other files by reference with the #include directive. The input stream comes from the
included file until the end is reached; it then reverts to the line after the #include in
the original file. The #includes can be nested.
FileName generally is a simple name that refers to the latest version of the source
with that name (which is stored in the corresponding node of the source global).
Alternatively, FileName can be a full global reference. If the last subscript of the
global reference is * (asterisk), the greatest subscript is substituted, thereby
simulating use of the latest version.
Syntax
#library [+]LibraryFileName,...
or
#library LibraryFileName[+],...
Definition
Parameter Description
LibraryFileName The name of a libraryfile in ^ZMSMMACSRC., or a full global
reference whose descendant nodes are the macros.
This command specifies libraries in the order which they are to be searched when a
macro definition is looked up. The presence of [+] modifies the existing search path,
so +LibraryFileName appends and LibraryFileName+ prepends the library to the
existing path. If [+] is not present, the path is entirely respecified.
Libraries are constructed by sources using the #makelib or #updlib directives. See
page 99 for additional information on libraries.
#makelib
Creates a macro library.
Syntax
#makelib LibraryName [GlobalReference]
Definition
Parameter Description
LibraryName The name of the macro library; the default is the current source
name.
GlobalReference The global in which to store the library; the default is
^ZMSMMAC.
The #makelib command initiates the creation of a macro library. Macro libraries are
stored in GlobalReference(LibraryName,1).
The #makelib command first clears the indicated library of all references. During this
process, if the system finds macro definitions that originate from sources other than
the current source, warnings that identify the macro and its original source are
logged.
Subsequent macro definitions then are added to the library. Different sources can
contribute to the same library, but only if #updlib is used.
Syntax
#nocomment
Definition
This command turns off the generation of comments that document the pre-expansion
form of lines with macros. It also applies to lines that sequentially follow the
#nocomment command. See also #comment.
#noroutine
Prevents generation of an M routine.
Syntax
#noroutine
Definition
The #noroutine command turns off the generation of an M routine by the
preprocessor. This command is placed at the top of sources that are used as include
files (such as header files) and files that are used to build macro libraries. See also
#routine.
#prefix
Defines the prefix used to identify a macro reference.
Syntax
#prefix [Literal]
Definition
Parameter Description
Literal A character string to serve as the macro introducer. If omitted,
the default prefix is reset.
This advanced command defines the prefix that is used to introduce macro
references.
The user can override the default, "%%", if a different prefix is preferred. For
example:
#prefix ~
#prefix $$$
#prefix {MACRO}
#routine
Specifies the name of a routine to be generated.
Syntax
#routine RoutineName
Definition
Parameter Description
RoutineName A valid M routine name.
#undefine
Removes a macro definition.
Syntax
#undefine MacroName
Definition
Parameter Description
MacroName A valid M expression.
This command removes the current definition of a macro name. This unstacking
process can either uncover and reinstate an earlier definition of the same macro
name, or reveal a library macro that was overlaid by a local definition.
This directive may be abbreviated as #undef.
Syntax
#updlib LibraryName [GlobalReference]
Definition
Parameter Description
LibraryName The name of the macro library; the default is the name of
the current source.
GlobalReference The global in which to store the library; the default is
^ZMSMMAC.
The #updlib command updates a macro library. Macro libraries are stored in
GlobalReference(LibraryName,1).
The #updlib command first clears the indicated library of references that originates
from the current source, leaving all libraries from other sources untouched.
Subsequent macro definitions are then added to the library. Different sources can
contribute to the same library when #updlib is used. When a library is to be defined
by a single source, consider using #makelib.
#x
Executes M code during preprocessing.
Syntax
#x Code
Definition
Code Valid M code.
During preprocessing, lines of M code can be executed. This command is used to set
and inspect variables or to generate code for output.
Routines
The following table provides a description of macro routines that are used by the
preprocessor.
Routine Description
%EDP Performs macro lookup, expansion, parameter substitution.
%EDP1 Processes directives, has supplementary entry points.
Globals
The following table provides a description of macro globals that are used by the
preprocessor.
Global Description
^ZMSMSRC The sources translated by the preprocessor are located, by default, in global
^ZMSMSRC:
^ZMSMSRC(SourceName,Version#,Line#) = Text
^ZMSMMAC Macro definitions are stored, by default, in global ^ZMSMMAC, which has
the following basic structure:
^ZMSMMAC(Library,Version#,MacroName,Line#) = Text
ANSI
The $merican 1ational 6tandard ,nstitute.
argument
An expression which controls what action will occur in the function or command with
which it is used.
array
An organized set of local or global elements or nodes which are referenced by
subscripts and a common variable name.
ASCII
The American Standard Code for Information Interchange. This code consists of 128
characters which comprise the standardized character set.
background job
A job that was started by the JOB command. This process runs in parallel with the
process which contained the JOB command.
baud
A term which describes the data transmission rate between two devices.
break
A command that interrupts program execution so that debugging can be performed.
Canonic number
A numeric value which has no leading or trailing zeros after the decimal point.
carriage return
A keyboard instruction, often used to indicate the end of a command. This key is
commonly marked RETURN, ENTER, or CR.
collating sequence
An order that is assigned to a grouping of subscripts. This sorting can be done in
either string or numeric sequence.
string sequence - All subscripts are treated as character strings and are stored in
ASCII sequence.
numeric sequence - Storage is in the order of Canonic numbers first, followed by the
non-numeric values in ASCII sequence.
command
The method by which the compiler is directed to perform a specific action.
comment
A brief phrase in the body of a routine which describes when the routine was written,
what the routine does, and so on. This is a non-executable line of code that begins
with a semicolon (;).
compiler
The language compiler is a highly sophisticated system program that scans each line
of M code, divides it into basic components, analyzes each component to ensure that
it is syntactically correct, and generates pseudo-machine code that can be processed
by the p-code interpreter.
CONFIG.MSM
A file found in the root directory or the local directory which contains information
about the MSM system you are running. When MSM is started, this file is read to
determine how MSM is to be set up.
configuration
The collection of hardware and software that comprises the entire computer system.
control characters
Characters from the standard ASCII set which have special meaning to the MSM
system. These characters are obtained by depressing the control key (usually marked
CTRL) at the same time that the associated control character is pressed.
cursor
The on-screen marker, usually a box or an underline, which indicates the location
where the next data entry will occur.
data
The information (letters, numbers, symbols) that is entered into the system for
processing or storage.
database
The location where storage of the data takes place in global arrays. In MSM, this is
where the MSM system was installed (database 0).
default
The value which is assumed as the entry to a prompt if the carriage return is
depressed. In MSM, default values are displayed between greater than ( > )and less
than ( < ) signs, for example: (<DEFAULT>).
descendant
Any array node on a lower subscript level which is reachable from that node and
shares the first 'x' subscripts in common. For example, the nodes R(3,4,5) and
R(3,6,4,7) are descendants of R(3).
expression
A character string which yields a value upon execution.
function
An action which gives users the ability to perform routine operations in a more
efficient manner. In MSM, a function begins with a dollar sign ($) or with a dollar
sign and the letter Z ($Z) for specialized M functions.
global
The permanent storage medium used by M. Data is stored in a global array or a
simple global variable and generally is placed on a disk system.
global variable
A reference name for data stored in a global on disk. These variables can be accessed
or changed by any user on the system with the proper protection level.
hardware
The physical components of the computer system other than the software; for
example, the computer itself (monitor, disk drive, and so on), the tape drive, and the
printer.
indirection
A method of using the value of an expression rather than the expression itself. The
symbol used to indicate that indirection is being used is the at-sign (@), followed by
the value that represents the expression.
interpreter
That part of the MSM system that processes the pseudo-machine code which has
been generated by the compiler.
job
A M partition separately managed by MSM with respect to execution and I/O.
journaling
A method of recording global SETs and KILLs while the system is in use. All
information is recorded in a journal entry which can be used to reconstruct the
database if necessary.
line
A string of characters ending with a specified read terminator (carriage return/line
feed).
line label
The optional name at the beginning of a routine line which identifies that line to the
system. This label is limited to eight characters and must begin with an alphabetic or
percent (%) character. Optionally, the label may contain parameter passing variables.
literal
A string, enclosed in quotations, which can be acted upon but not changed by a
command. The literal may contain any valid ASCII character; however, some of
these characters may be excluded because they have special meaning to the MSM
system.
local variable
Any variable that exists within memory only. These variables are unique to a
particular job and are valid only for the duration of the job's execution.
map
The space allocated for disk storage. Each map consists of 512 blocks (each 1024
bytes in size).
M
Acronym for Massachusetts General Hospital Utility Multi-Programming System.
This system was developed in the late 1960s to handle storage, retrieval, and
manipulation of large amounts of medical data. It is one of only four ANSI standard
languages.
naked reference
A shortcut method for referring to a particular global node. The naked reference can
generally be used wherever a global reference is permitted. The naked reference can
be specified for a previously referenced node by using a circumflex (^), followed by
the unique portion of the descendant's subscript.
node
That element of a global array addressed by the name common to all members of the
array and a unique subscript.
parameters
The collection of guidelines for the usage of a particular device.
peripherals
A collection of devices, both physical and logical, which are associated with the
MSM system. These devices are used to gain access to printers, terminals, and
sequential devices, and to examine or modify memory contents or alternate disk
storage.
programmer mode
The mode which permits the user to directly enter M commands to the interpreter.
Access is gained through entry of a valid UCI and PAC.
prompt
A system message which requires user input in response.
routine types
library routines - A group of utility programs that is accessible to all users on the
system.
system manager routines - Routines that can be accessed only by entering the
Manager's UCI (MGR).
run mode
The method used to directly access a routine in a particular UCI. Access is obtained
by entering a valid UCI and routine name stored in that UCI.
sparse array
An array that contains space only for those elements which are actually defined.
special variables
A group of variables ($ZA, $ZB, and $ZC) which have special meaning to the MSM
system. These variables are used to indicate status information about the results of
the last operation performed.
stack
An area of the MSM system that is set aside for nesting of subroutines resulting from
execution commands.
stap
An area of the MSM system that is set aside for complex expression nesting.
string
Any set of ASCII characters with a maximum length of 255 characters.
string literal
A string of characters enclosed in double quotes within the context of a line.
subroutine
A collection of commands which together allow control to pass from the routine to
the subroutine and back to the main routine. Subroutines generally are used when
multiple recurring tasks are required for execution of the main routine.
subscript
A numeric or string interpreted value appended to a local or global variable used to
identify a specific element or node in an array. Subscripts must be enclosed in
parentheses and are separated by commas when more than one is indicated.
SYSGEN
The system generation utility used to specify one or more configurations to the MSM
system. These configurations are used by the system at startup to initialize the system
with the defined parameters. This is done via an interactive dialogue with MSM
which supports on-screen help for any prompted value.
terminators
The specified set of control characters which are used to terminate a read operation.
MSM uses a default value of line feed, carriage return ($C(10,13), but permits the
user to alter this value through use of proper parameters associated with the current
device.
tied terminal
A mode which is used to force a terminal to automatically start up a specific routine
in a UCI.
timeout
A timing convention which allows the user to specify how long the system should
attempt to perform a given command before proceeding. It is expressed in the format
of a colon (:), followed by an integer which is appended to a READ, OPEN, or JOB
command.
utilities
library utilities - A group of utilities that are used to develop application programs
which require commonly performed functions.
system manager utilities - Utilities that are designed for use by the system manager
and that ensure proper system performance. These routines can be accessed only
from the Manager's UCI (MGR).
variable
A symbolic name for a location where data is stored. In MSM, there are three type of
variables:
local variables - Variables that are stored only in memory.
global variables - Variables that are stored in arrays for permanent storage on disk.
special variables - Variables that hold special meaning to the MSM system.
V
Values
Negative 151
Variables 103
Deletion 73
Global 78, 90, 107, 110
Local 19, 78, 80, 90, 107, 110
Special 80, 223
Stacked 80
VIEW Command 101, 105
View Device Error 276
Volume
Group 68, 71, 101, 177, 217, 219, 252
Name 217
Number 217, 219
W
WRITE Command 103
X
XECUTE Command 22, 105, 227, 237, 249, 253, 269
With QUIT 84
Z
ZALLOCATE Command 57, 64, 66, 107, 240
ZDEALLOCATE Command 110
ZFLUSH Command 111
ZGO Command 50, 112, 274
ZHOROLOG Command 113
ZINSERT Command 115, 238, 274, 275
ZLOAD Command 117, 238, 274