PillarSoft

http://www.pillarsoft.net/os-2-software/rexx/error-code-subroutines-command-line-and-visprorexx.shtml

Error code subroutines, command line and VisProRexx (Beginning level)

Contributed by: Doug Rickman, Global Hydrology and Climate Center, MSFC, NASA

This is aimed at beginning REXX users.

These are simple subroutines which use the various SIGNALs. There are a couple of variations included, those that use say and those that generate a VisProRexx message box. I also include a fairly complete example of an Error: subroutine in addition to the simple version. This is aimed at beginning REXX users.


 


/*****************************************************************************/
/***************  Error Condition Handlers                     ***************/
/* The first set works using say.  The second set works inside of VisPro.    */

/* Place these lines at beginning of code. */
signal on Halt
signal on NotReady
signal on error
signal on failure
signal on novalue
signal on syntax


/* Place these lines anywhere in the code. */
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Halt:                                 -------------*/
Halt:
say 'This is a graceful exit from a Cntl-C'
exit
/* --- end  subroutine - Halt:                                  -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - NotReady:                             -------------*/
NotReady:
say 'It would seem that you are pointing at non-existant data. The program',
    'line that generated this error is' SIGL
return 0
/* --- end  subroutine -  NotReady:                             -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Error: simple version                 -------------*/
Error: 
say 'Error: As if it wasn't obvious.The program line that generated this',
    'error is' SIGL
return 0
/* --- end  subroutine -  Error:                                -------------*/
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Error: detailed version               -------------*/
error:
say
say '__________________________________________________'
say 'Error Condition  occurred at line ' SIGL
say 'Condition:' name condition('c')
say 'Instruction:' condition('i')
say 'Description:' condition('d')
say 'Status:' condition('s')
say 'RC: 'rc
Say SysGetMessage(rc)
say '__________________________________________________'
say
return 0
/* --- end  subroutine -  Error:                                -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Failure:                              -------------*/
failure:
say 'Failure, how is this for a cryptic message? The program line that',
    'generated this error is' SIGL
return 0
/* --- end  subroutine -  Failure:                              -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Syntax:                               -------------*/
syntax:
say 'Sin is expensive, partially because there is a tax on it.  The program',
     'line that generated this error is' SIGL
return 0
/* --- end  subroutine -  Syntax:                               -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - NoValue:                              -------------*/
NoValue:
say 'The currency has no value.  The program line that generated this error',
         'is' SIGL
return 0
/* --- end  subroutine -  NoValue:                              -------------*/
/* --------------------------------------------------------------------------*/


/* Vispro format error messages.                                             */
signal on NotReady
signal on failure
signal on novalue
signal on syntax

/* --------------------------------------------------------------------------*/
/* --- begin subroutine - NotReady:                             -------------*/
NotReady:
response=VpMessageBox(window,'Oops!','It would seem that you are pointing at',
         'non-existant data. The program line that generated this error is',
         SIGL)
return 0
/* --- end  subroutine -  NotReady:                             -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Failure:                              -------------*/
failure:
response=VpMessageBox(window,'Oops!','Failure, The program line that',
         'generated this error is' SIGL)
return 0
/* --- end  subroutine -  Failure:                              -------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - Syntax:                               -------------*/
syntax:
response=VpMessageBox(window,'Oops!','Sin is expensive, partially because',
         'there is a tax on it. The program line that generated this error',
         'is' SIGL)
return 0
/* --- end  subroutine -  Syntax:                               -------------*/
/* --------------------------------------------------------------------------*/
/* --------------------------------------------------------------------------*/
/* --- begin subroutine - NoValue:                              -------------*/
NoValue:
response=VpMessageBox(window,'Oops!','The currency has no value. The program',
         'line that generated this error is' SIGL)
return 0
/* --- end  subroutine -  NoValue:                              -------------*/
/* --------------------------------------------------------------------------*/