<monitor element>
──┬─<simple variable>──────┬───────────────────────────────────────────┤ ├─<subscripted variable>─┤ ├─<label identifier>─────┤ └─<array identifier>─────┘
The diagnostic information produced depends on the forms of the monitor elements. When the LINEINFO compiler control option is TRUE and a file identifier is specified in the MONITOR declaration, a stack number, an at sign (@), a code address, and a sequence number are printed in front of the symbolic name of the monitor element (for example, 0143 @ 003:0003:4 (00007000)).
Diagnostic information is given for the specified monitor elements as follows:
-
If the monitor element is a simple variable or a subscripted variable, the symbolic name and the previous and new values of the variable are printed (for example, B =0:=13).
-
If the monitor element is a label identifier, the symbolic name of the label is shown (for example, LABEL L).
-
If the monitor element is an array identifier, the symbolic name of the array, the subscript of the element, and the previous and new values of the changed array element are printed (for example, A[12] =0:=12).
If the monitor element is to be assigned a value, this assignment must be done by the monitoring procedure. This value also can be assigned to the procedure value to be used, for example, in evaluating the remainder of an expression in which the assignment is embedded. In the example under “Monitor Element as an Array Identifier,” the assignment statement NAME:= MON:= VAL; allows the subsequent use of the value assigned to the monitor element.
Monitor Element as a Simple Variable
When the monitor element is a simple variable, the format of the monitoring procedure must be as follows:
REAL PROCEDURE MON(NAME,VAL,SPELL);
The procedure must be of the same type as the monitor elements. The procedure must have three parameters:
-
The first parameter, NAME, is a call-by-name parameter of the same type as the monitor element. The parameter NAME is passed a reference to the monitor element, and it is normally used to store the value of the second parameter, VAL.
-
The second parameter, VAL, is also of the same type as the monitor element, but it is a call-by-value parameter and is passed the new value to be assigned to the monitor element.
-
The third parameter, SPELL, must be a call-by-value real variable that is passed the name of the monitor element as a string of characters. Only the first six characters of the symbolic name are passed to this formal parameter. If the symbolic name is less than six characters long, it is left-justified, and trailing blanks are added, up to six characters.
Monitor Element as a Label Identifier
When the monitor element is a label identifier, the format of the monitoring procedure must be as follows:
The procedure must be untyped and must have only one parameter. This parameter is a call-by-value real variable that is passed the first six characters of the symbolic name. If the symbolic name is less than six characters long, it is left-justified, and trailing blanks are added, up to six characters. The monitoring procedure could compare this name to the symbolic names in the monitor list in order to identify a particular label.
Monitor Element as an Array Identifier
When the monitor element is an array identifier, the declaration of the monitoring procedure must be as follows:
PROCEDURE MON(SPELL);
REAL PROCEDURE MON(D1,...,Dn,NAME,VAL,SPELL);
The parameters D1 through Dn of the procedure are index parameters that are passed the subscripts for each dimension of the array element that is modified. There must be as many index parameters as the array has dimensions. Each index parameter is a call-by-value integer. The last three parameters are the same as in the simple variable form, except that NAME and VAL are simple variables of the same type as the array.
The value being assigned to the array element also can be assigned to the procedure value to be used, for example, in evaluating the remainder of an expression that contains the array element.
The following procedure can be used to monitor a two-dimensional real array so that the values in the array never become negative:
REAL PROCEDURE MON(D1,D2,NAME,VAL,SPELL);
VALUE D1,D2,VAL,SPELL;
REAL NAME,VAL;
REAL SPELL;
INTEGER D1,D2;
BEGIN
IF VAL < 0 THEN
GO TO ERROREXIT; % BAD GO TO
NAME := MON := VAL; % RETURN VALUE FOR FURTHER USE
END;The following statements are equivalent to each other, where A is monitored by MON. A is a two-dimensional array declared in the same program where the monitoring procedure MON is declared. The first assignment statement assigns 4 to A[I,J], as does the second statement because inside the procedure MON the fourth parameter (VAL) is assigned to the third parameter (NAME).
B := A[I,J] := 4; B := MON(I,J,A[I,J],4,"A");

