Mainframe Utility: CALCULAT

Return to Mainframe Utilities Page

Module


PROC 1 EQUATION
/**** SET MESSAGE DISPLAY ON/OFF BASED ON THE DEBUG SWITCH ***/
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN CONTROL MSG LIST CONLIST SYMLIST NOFLUSH
ELSE CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
IF &STR(&EQUATION) = HELP THEN GOTO HELPSEC
/**********************************************************************
/* UTILITY : CALCULAT                                                 *
/* AUTHOR : DAVID LEIGH                                               *
/* DATE : 10-20-90                                                    *
/* FUNCTION : THIS CLIST PROCESSES ARITHMATIC CALCULATIONS AND        *
/*            DISPLAYS A MESSAGE WITH THE RESULT.                     *
/**********************************************************************

SET ZEDLMSG = &STR(&EQUATION = &EVAL(&EQUATION))
ISPEXEC SETMSG MSG(UTLZ000)

EXIT

HELPSEC: +                                                              02480000
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)                             02490000
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR CALCULAT UTILITY +            02490000
                   *** NO PROCESSING PERFORMED ***)                     02490000
ISPEXEC SETMSG MSG(UTLZ000)                                             02490000
EXIT
            


Documentation


 The CALCULAT CLIST allows you to pass an arithmatic expression and then
 CALCULAT returns a message with the evaluation of the arithmatic expression.

 To use it, you type TSO CALCULAT xxxxxx where xxxxxx is some equation.  It is
 important that you do not have any spaces in your equation.  Consequently, TSO
 CALCULAT 1 + 1 would be incorrect, but TSO CALCULAT 1+1 would be correct and
 would return a message like "1+1 = 2".

 Obviously, CALCULAT can handle a little equations a bit more complex than that.
 You may use parentheses and the standard add, subtract, mulitply, and divide
 symbols (+, - , *, /).
            


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.