The Datatype function is used to assess whether a value is of a certain type.
result = Datatype( string [, type ] ) |
A Alphanumeric -- returns 1 if string contains only letters and digits
B Binary -- returns 1 if string contains only '0' or '1' digits
L Lower case -- returns 1 if string contains only lower case letters
M Mixed case -- returns 1 if string contains only letters
N Number -- returns 1 if string is a Rexx numeric value
S Symbol -- returns 1 if string contains only characters that are valid in Rexx symbols
U Upper case -- returns 1 if string contains only upper case letters
W Whole number -- returns 1 if string is a Rexx whole number as constrained by the current setting of numeric digits.
Observe: when the number of digits within a whole number exceeds the numeric digits setting, exponential notation is necessary, and the number could be rounded. Consequently, such large numbers are not considered to be a whole number.
X heXadecimal -- returns 1 if string contains only hexadecimal characters. Spaces are permitted at hexadecimal digit pair boundaries.
In the above cases, when the type of the value does not match 0 is returned.
When the type argument is omitted, the Datatype function returns
NUM if string is a Rexx numeric value
CHAR if string is NOT a Rexx numeric value
Examples:
say Datatype( ' 7 ') -- shows NUM say Datatype( 'shazam' ) -- shows CHAR say Datatype( ' 7 ', 'N' ) -- shows 1 say Datatype( ' 7.1 ', 'W' ) -- shows 0 say Datatype( 'm3', 'A' ) -- shows 1 say Datatype( 'shazam', 'L' ) -- shows 1 say Datatype( 'Shazam', 'M' ) -- shows 1 say Datatype( 'SHAZAM', 'U' ) -- shows 1 say Datatype( 'm.3', 'S' ) -- shows 1 say Datatype( '1101', 'B' ) -- shows 1 say Datatype( '2BAD', 'X' ) -- shows 1 |