z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Testing Input with Built-In Functions

z/OS TSO/E REXX User's Guide
SA32-0982-00

Some of the built-in functions provide a convenient way to test input. When an interactive exec requests input, the user might respond with input that is not valid. For instance, in the example Using Comparison Expressions, the exec requests a dollar amount with the following instructions.
SAY 'What did you spend for lunch yesterday?'
SAY 'Please do not include the dollar sign.'
PARSE PULL last
If the user responds with a number only, the exec will process that information correctly. If the user responds with a number preceded by a dollar sign or with a word, such as nothing, the exec will return an error. To avoid getting an error, you can check the input with the DATATYPE function as follows:
DO WHILE DATATYPE(last) \= 'NUM'
  SAY 'Please enter the lunch amount again.'
  SAY 'The amount you entered was not a number without a dollar sign.'
  PARSE PULL last
END

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

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014