z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Creating arithmetic expressions from user-supplied input - the CALC CLIST

z/OS TSO/E CLISTs
SA32-0978-00

The CALC CLIST, shown in Figure 1, contains a PROC statement that requires three input strings from the invoker:
  • A numeric value
  • An arithmetic operator
  • Another numeric value.

The CLIST creates an arithmetic expression using the positional parameter variables that represent these three values. A WRITE statement displays a message made up of the unevaluated expression, an equal sign, and the evaluated expression. CALC contains no validity-checking statements; therefore, input that does not meet the above requirements causes the &EVAL; built-in function to fail and generate an error code.

Figure 1. The CALC CLIST
 PROC 3 FVALUE OPER LVALUE

 /**********************************************************************/
 /* DISPLAY THE ENTIRE EQUATION AT THE TERMINAL, INCLUDING THE RESULT  */
 /* OF THE EXPRESSION.                                                 */
 /**********************************************************************/

 WRITE &FVALUE&OPER&LVALUE = &EVAL(&FVALUE&OPER&LVALUE)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014