Unless there is a reason to handle a nonzero rc (e.g. error correction 
code, or special a special message), then Phil's simple example would be 
better handled with an existing rexx convention:

Signal ON ERROR
address command 'somecmd'
...
then either leave Signal ON ERROR active - generally not a bad setting 
unless you are specifically planning to accept and handle nonzero return 
codes, or issue: Signal OFF ERROR.  (Forgive the mixed-case emphasis - I 
prefer to emphasize the potential for logical path flow changes.)

Signal ON ERROR (along with Signal ON SYNTAX, and Signal ON NOVALUE) will 
help identify failures in code that may otherwise require significant 
debugging.  Actually, I seem to remember Phil suggesting them in the past? 
 

Rexx provides help when asked -- let it. 

Mike Walter
Hewitt Associates
The opinions expressed herein are mine alone, not my employer's.



"Kris Buelens" <kris.buel...@gmail.com> 

Sent by: "The IBM z/VM Operating System" <IBMVM@LISTSERV.UARK.EDU>
02/25/2010 09:06 AM
Please respond to
"The IBM z/VM Operating System" <IBMVM@LISTSERV.UARK.EDU>



To
IBMVM@LISTSERV.UARK.EDU
cc

Subject
Re: An SFS aid







2010/2/25 Phil Smith III <li...@akphs.com>
...... 
Another great use for SIGNAL (and one that your rules do admit to) is for 
error exits. I hate code like this:

address command 'somecmd'
if rc <> 0 then do
  say 'That was an error, rc='rc
  exit rc
end

Far better IMHO is:

address command 'somecmd'
if rc <> 0 then signal Error

This keeps the mainline more compact and readable, and it's pretty clear 
to the reader that "Hey, we're going somewhere to handle the error and we 
ain't comin' back"!

We now return you to the actual thread on SFS.

...phsiii

I agree with the "use Signal sometimes", in cases where one will not 
return, it is more clear indeed.  But, the example above "if rc<>0 then 
signal Error" isn't very practical: you cannot pass parameters.  So I have 
a Call to my errorexit: routine.  The name of the called routine makes it 
clear to the reader that one will not return from there.

if rc<>0 then call errExit rc,'Something was wrong','Please try again'
.......
ERREXIT: /* general errorexit routine */
 parse upper source . . myname . 
 do i=2 to arg()   /* give errormessages (if any) */
    say myname':' arg(i)
 end
 exit arg(1)

I guess we devoted some chapter to it in our selfstudy Telecourse:
   http://www.vm.ibm.com/download/packages/descript.cgi?TCVM1
-- 
Kris Buelens,
IBM Belgium, VM customer support




The information contained in this e-mail and any accompanying documents may 
contain information that is confidential or otherwise protected from 
disclosure. If you are not the intended recipient of this message, or if this 
message has been addressed to you in error, please immediately alert the sender 
by reply e-mail and then delete this message, including any attachments. Any 
dissemination, distribution or other use of the contents of this message by 
anyone other than the intended recipient is strictly prohibited. All messages 
sent to and from this e-mail address may be monitored as permitted by 
applicable law and regulations to ensure compliance with our internal policies 
and to protect our business. E-mails are not secure and cannot be guaranteed to 
be error free as they can be intercepted, amended, lost or destroyed, or 
contain viruses. You are deemed to have accepted these risks if you communicate 
with us by e-mail. 

Reply via email to