DATATYPE
returns NUM if you specify only string and if
string is a valid REXX number that can be added to 0 without error;
returns CHAR if string is not a valid number.
If you specify type, returns
1 if
string matches the type; otherwise returns 0. If
string is null, the function returns 0 (except when
type is X, which returns 1 for a null
string). The following are valid types. (Only the capitalized letter is needed; all characters following it are ignored.
Note that for the hexadecimal option, you must start your string specifying the
name of the option with x rather than h.) - Alphanumeric
- returns
1if string contains only characters from the rangesa–z,A–Z, and0–9. - Binary
- returns
1if string contains only the characters0or1or both. - C
- returns
1if string is a mixed SBCS/DBCS string. - Dbcs
- returns
1if string is a DBCS-only string enclosed by SO and SI bytes. - Lowercase
- returns
1if string contains only characters from the rangea–z. - Mixed case
- returns
1if string contains only characters from the rangesa–zandA–Z. - Number
- returns
1if string is a valid REXX number. - Symbol
- returns
1if string contains only characters that are valid in REXX symbols. (See Tokens.) Note that both uppercase and lowercase alphabetics are permitted. - Uppercase
- returns
1if string contains only characters from the rangeA–Z. - Whole number
- returns
1if string is a REXX whole number under the current setting of NUMERIC DIGITS. - heXadecimal
- returns
1if string contains only characters from the rangesa–f,A–F,0–9, and blank (as long as blanks appear only between pairs of hexadecimal characters). Also returns1if string is a null string, which is a valid hexadecimal string.
DATATYPE(' 12 ') -> 'NUM'
DATATYPE('') -> 'CHAR'
DATATYPE('123*') -> 'CHAR'
DATATYPE('12.3','N') -> 1
DATATYPE('12.3','W') -> 0
DATATYPE('Fred','M') -> 1
DATATYPE('','M') -> 0
DATATYPE('Fred','L') -> 0
DATATYPE('?20K','s') -> 1
DATATYPE('BCd3','X') -> 1
DATATYPE('BC d3','X') -> 1Note: The DATATYPE function tests the meaning or type of characters in a string, independent of the
encoding of those characters (for example, ASCII or EBCDIC).
