In many programming languages the validation of input can be a boring task involving lots of code. In REXX it is in many cases quite easy by using the function DATATYPE. My favourite is DATATYPE(variable, 'W'), which validates whether the contens of variable is an integer or not. The more peculiar thing about the function is that it returns 0 if variable is not of the specified datatype and 1 if it is. This behaviour makes it quite useful in an IF statement in the following way:
Please notice that DATATYPE may be used with only one parameter. In this case the function suddenly returns either the value NUM or CHAR which is quite odd. I also like using DATATYPE(variable, 'S'), which validates whether variable contains a valid REXX symbol or not. This is an amazing feature especially if you like to use the INTERPRET command or the VALUE function.