I include the following code in every REXX EXEC that I code.  It’s taken from a 
great article by Walter Pachl, IBM Retiree, entitled, “What's wrong with Rexx?” 
 You can find it at…
www.rexxla.org/events/2004/walterp.pdf

So at the top of the code, I have…
/* REXX */
SIGNAL ON NOVALUE                       /* Enable the conditions and  */
SIGNAL ON SYNTAX                        /* point at reasonable        */
SIGNAL ON FAILURE                       /* condition handling         */
SIGNAL ON HALT

Then at the bottom, I have…

/*
  Condition handling
 
  Taken from "What's wrong with Rexx?" by Walter Pachl, IBM Retiree
  Downloaded from www.rexxla.org/events/2004/walterp.pdf
 
*/
NOVALUE:
SAY 'Novalue raised in line' SIGL   /* line in error number       */
SAY SOURCELINE(SIGL)                /* and text                   */
SAY 'Variable' CONDITION('D')       /* the bad variable reference */
SIGNAL Lookaround                   /* common interactive code    */
 
SYNTAX:
SAY 'Syntax raised in line' SIGL    /* line in error number       */
SAY SOURCELINE(SIGL)                /* and text                   */
SAY 'rc='rc '('errortext(rc)')'     /* the error code and message */
 
HALT:
Lookaround:                         /* common interactive code    */
/* IF user_interface = 'FORE' THEN DO  when running in foreground */
   SAY 'You can look around now.'   /* tell user what he can do   */
   TRACE ?R                         /* start interactive trace    */
   NOP                              /* and cause the first prompt */
   /* END */
ctr.return_code = 16
SIGNAL Quit

As Walter pointed out in his article, having this code prevents a lot of 
debugging headaches.

Also, Paul Gilmartin mentioned the SYMBOL(name) function which will tell you if 
a variable has a value assigned.  There is also the DATATYPE function which 
will tell you the type of data the value is.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to