Testing Input with Built-In Functions

About this task

Some of the built-in functions provide a convenient way to test input. When a program uses input, the user might provide input that is not valid. For instance, in the example of using comparison expressions in section Using Comparison Expressions, the program uses a dollar amount in the following instruction.
PARSE PULL yesterday  /* Gets yesterday's price from input stream */
If the program pulls only a number, the program processes that information correctly. However, if the program pulls a number preceded by a dollar sign or pulls a word, such as nothing, the program returns an error. To avoid getting an error, you can check the input with the DATATYPE function as follows.
IF DATATYPE(yesterday) \= 'NUM'
THEN DO
       SAY 'The input amount was in the wrong format.'
       EXIT
     END

Other useful built-in functions to test input are WORDS, VERIFY, LENGTH, and SIGN.


Task Task

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/rvse035.html