Previous Topic: &TRANS

Next Topic: &VARTABLE


&TYPECHK

Returns one of a supplied list of data types based on supplied variables.

&TYPECHK (type1, type2 ....) &var1 [ &var2 .... &varn ]

Allows you to test one or more variables against a list of type attributes.

&TYPECHK is a built-in function and must be used to the right of an assignment statement. The statement returns a value after assignment that represents the first matching type attribute that was found or else a null value.

The first supplied value is tested against each of the type values specified in the list until a match is found. If the variable's type attribute does not match any in the list, then a null value is returned. If a match is found, then that type is returned.

If more than one source value is supplied, then &TYPECHK produces one of the following results:

Operands:

type

One or more type values against which the source values are to be tested. A single type value is coded on its own, or multiple values is coded enclosed in parentheses. Valid values and value meanings for type are:

&var

This operand is a system or user variable. Multiple variables is coded.

Examples: &TYPECHK

&1 = ABC
&A = &TYPECHK (NUM,ALPHA) &1

Result: &A = ALPHA

&1 = +111
&A = &TYPECHK (NUM,SIGNNUM) &1

Result: &A = SIGNNUM

&1 = 1234567890
&A = &TYPECHK (SIGNNUM,NUM) &1

Result: &A = SIGNNUM

&1 = 12345678901
&A = &TYPECHK (SIGNNUM,NUM) &1

Result: &A = NUM (Because the number exceeds the maximum for NCL arithmetic).

&1 = 123 
&2 = ABC  
&A = &TYPECHK (NUM,HEX) &1 &2

Result: &A is set to NULL, because &1 and NUM match but NUM does not match &2.

Notes:

By using &TYPECHK to test variables before using them in arithmetic functions, you can avoid the procedure being terminated with an invalid arithmetic function error condition due to invalid input.

The NUM type applies to variables containing a number with no leading sign. This number can, however, be too large for arithmetic operations. To determine whether you can use a numeric variable in arithmetic, check its type attribute for SIGNNUM or REAL. SIGNNUM is returned if the number is a positive or negative integer that is used in arithmetic.

ALPHA means that the variable contains alphabetic characters only, and no national characters. ALPHANUM means that the variable can contain alpha and numeric characters, but not necessarily a mixture.

When working with full-screen procedures, Panel Services provides facilities that automatically perform validation of data entered by the operator.

Note: For more information, see the Network Control Language Programming Guide.

If &TYPECHK is used to test a list of variables which include NULL values, then NCL variable substitution logic does not let it recognize the existence of those null variables.