Product Site

5.1.7.59. dataType

Returns NUM if you specify no argument and the receiving string is a valid Rexx number that can be added to 0 without error. It returns CHAR if the receiving string is not a valid number.

If you specify type, it returns .true if the receiving string matches the type. Otherwise, it returns .false. If the receiving string is null, the method returns .false (except when the type is X or B, for which dataType returns .true for a null string). The following are valid types. You need to specify only the capitalized letter, or 9 for the 9Digits option. The language processor ignores all characters following it.
Alphanumeric

returns .true if the receiving string contains only characters from the ranges a-z, A-Z, and 0-9.
Binary

returns .true if the receiving string contains only the characters 0 or 1, or whitespace. Whitespace characters can appear only between groups of 4 binary characters. It also returns .true if string is a null string, which is a valid binary string.
Internal whole number

returns .true if the receiving string is a Rexx whole number that built-in functions will accept. Rexx built-in functions internally work with NUMERIC DIGITS 9 for 32-bit systems or NUMERIC DIGITS 18 for 64-bit systems.
Lowercase

returns .true if the receiving string contains only characters from the range a-z.
Mixed case

returns .true if the receiving string contains only characters from the ranges a-z and A-Z.
Number

returns .true if receiving_string~dataType returns NUM.
lOgical

returns .true if the receiving string is exactly 0 or 1. Otherwise it returns .false.
Symbol

returns .true if the receiving string is a valid symbol, that is, if SYMBOL(receiving_string) does not return BAD. See also Section 1.10.4.4, “Symbols”. Note that both uppercase and lowercase alphabetic characters are permitted.
Uppercase

returns .true if the receiving string contains only characters from the range A-Z.
Variable

returns .true if the receiving string could appear on the left-hand side of an assignment without causing a SYNTAX condition.
Whole number

returns .true if the receiving string is a whole number under the current setting of NUMERIC DIGITS.
heXadecimal

returns .true if the receiving string contains only characters from the ranges a-f, A-F, 0-9, and whitespace characters (as long as whitespace characters appear only between pairs of hexadecimal characters). Also returns .true if the receiving string is a null string.
9 Digits

returns .true if receiving_string~dataType("W") returns .true when NUMERIC DIGITS is set to 9.
Example 5.97. String class — datatype method
Say " 12 "~dataType          -->   "NUM"
Say ""~dataType              -->   "CHAR"
Say "123*"~dataType          -->   "CHAR"
Say "12.3"~dataType("N")     -->    1
Say "12.3"~dataType("W")     -->    0
Say "Fred"~dataType("M")     -->    1
Say ""~dataType("M")         -->    0
Say "Fred"~dataType("L")     -->    0
Say "?20K"~dataType("s")     -->    1
Say "BCd3"~dataType("X")     -->    1
Say "BC d3"~dataType("X")    -->    1
Say "1"~dataType("O")        -->    1
Say "11"~dataType("O")        -->   0

Note

The dataType method tests the meaning or type of characters in a string, independent of the encoding of those characters (for example, ASCII or EBCDIC).