NET/MASTER Network Control Language (NCL) Reference Manual
TYPECHK
Built-in Functions
106126 Tandem Computers Incorporated 4–91
string
contains the data to be checked. The first string is checked against each type
specified in
typelist
, in turn. Once a type match is found, all additional string
arguments must match that same type. If a type match is found, that type is
returned. In all other cases, a null string is returned.
Considerations
If only one string is specified, the type matched is returned. If additional string
arguments are specified, they must all match the same type as the first string. If
they do not, a null string is returned. If they all match, the type name is returned.
If more than a single type check is specified, the types must be enclosed in
parentheses and surrounded by quotes; a compilation error results otherwise. See
the given examples.
See also DATATYPE, which tests a string to determine if it contains a specific data
type.
Examples
In the following example, the string “ABC” is checked to determine whether it is a
numeric (NUM) or an alphabetic (ALPHA) string. Notice how the variable &C is
coded. The value returned is ALPHA:
&A = ALPHA
&B = NUM
&C = (&A","&B)
&D = ABC
&RESULT = TYPECHK(&C,&D)
In the following example, the string “XYZ” is checked to determine whether it is a
hexadecimal (HEX) or binary (BIN) string. The string is neither of these, so a null
value is returned:
SAY TYPECHK(“(HEX,BIN)”,XYZ)
In the following example, the string “0F0” is checked to determine whether it is a
hexadecimal (HEX) or binary (BIN) string. The string is a valid hexadecimal value, so
HEX is returned:
SAY TYPECHK(“(HEX,BIN)”,0F0)
In the following examples, a single type specification is used. All the examples give
the same result: HEX. These examples are included to show the possible ways of
specifying
typelist
:
SAY TYPECHK(HEX,0F0)
SAY TYPECHK((HEX),0F0)
SAY TYPECHK(“(HEX)”,0F0)