Rexx - DataType
This method returns the value of NUM if the input is a valid number else it will return the value of CHAR. You can also specify if you want to compare the input value to a NUM or CHAR value. In each case, the value returned will be either 1 or 0 depending on the result.
Syntax
DATATYPE(String,type)
Parameters
String − The string value for which the datatype needs to be determined.
Type − Optional type against which the datatype need to be compared to.
Return Value
This method returns the value of NUM if the input is a valid number else it will return the value of CHAR. You can also specify if you want to compare the input value to a NUM or CHAR value. In each case, the value returned will be either 1 or 0 depending on the result.
Example
/* Main program */
say DATATYPE(" 12345 ")
say DATATYPE("")
say DATATYPE("12345*")
say DATATYPE("123.4","N")
say DATATYPE("123.4","W")
When we run the above program we will get the following result.
Output
NUM CHAR CHAR 1 0
rexx_built_in_functions.htm
Advertisements