NET/MASTER Network Control Language (NCL) Programmer's Guide

The Structure of Mapped Data Object (MDO) Variables
Working With Mapping Services
10–14 106160 Tandem Computers Incorporated
The Key Field of an Element Header
The key field of an element in an MDO variable uniquely identifies the element. The
value contained in the key field represents the encoded name of the element definition
that Mapping Services uses to interpret the element. The name of the definition in
Figure 10-2 is MSGATTR. This is called a symbolic name.
The symbolic name of an element definition is represented internally in an MDO
variable. The internal representation of a symbolic name is called a key value. Figure
10-2 shows the key value for MSGATTR is (the decimal number) 2. In the element of
an MDO variable mapped by the map $MSG, when Mapping Services encounters the
key value of 2, Mapping Services interprets it to mean: "Use the definition for the
element MSGATTR when analyzing this element."
The length of the key field is included in the length of an element. Figure 10-2 shows
this is fixed at 2 bytes in MSGATTR.
When an MDO variable is created, Mapping Services automatically inserts the name of
the definition used to interpret an element in the key field of the element header.
When you refer to an element from an NCL procedure, Mapping Services uses the
name to interpret the structures within the element.
The key field of an element header contains internal Mapping Services data. You
cannot directly access the key field of an element header from an NCL procedure.
However, the following NCL procedure shows how you can use the C2D (returns the
decimal value of a string) and SUBSTR (returns a substring) built-in functions to
indirectly access the key value of an element:
zex1006n: PROCEDURE
/* MSGPROC procedure to obtain element key value */
DO FOREVER
MSGREAD VARS=&word*
IF &word1 = "TEST" THEN DO
&key_value = C2D( SUBSTR( &$MSG., 3, 2 ) )
SAY "Key value of &$MSG.TEXT is "&key_value
MSGCONT
END
ELSE
MSGCONT
END
END zex1006n
Using this technique requires an understanding of the structure of the element.