On 2014-04-14 10:50, Frank M. Ramaekers wrote:
> I've only done a couple of these before and don't have any good
> debugging techniques. I've run into a problem on this:
>
Reformatting for compactness:
> /* */
> Trace "O"
> Signal On Error Name Bad_Error
> Signal On Syntax Name Bad_Syntax
> Signal On NoValue Name Bad_NoValue
>
I am not much of a fan of all these handlers:
o I am not a devout follower of the Dutchmen's "GOTO considered harmful!"
but this goes to the other extreme. Rexx's default error handling
is more legible than a novice is likely to code. But I always code
"signal on error" and code no handler. It catches inadvertently
undefined variables; I interpret the traceback, and fix whatever I
consider a problem. Where I may have deliberately undefined symbols,
I use the symbol() and value() functions to deal with them. More often,
I just surround them with apostrophes to make them constants.
> RecNo=0
> Parse arg OmitRec . "("
> "PEEKTO Record"
> Do while rc==0
> RecNo=RecNo+1
> If RecNo\==OmitRec then
> "READTO"
> If rc\==0 then
>
Your handler says you can never get here.
> Exit rc
> "PEEKTO Record"
> End /* while */
>
OK. You can't possibly fall out of this loop. Have the courage of
your conviction by supplying "exit 999" or the like here.
> Bad_Error:
> If rc==12 then
> rc=0
> Exit rc
>
I think it's more legible to handle errors inline, as you tried to do
with "If rc\==0 then ...", rather than in a remote handler that one
must scan forward to see what's happening.
> Bad_Syntax:
> Exit 13
>
I _never_ provide a Syntax handler. All yours does is to suppress the
traceback which might disclose the point of the error.
> Bad_NoValue:
> Exit 14
>
Your RC=14 is probably coming from here. If you omitted the handler,
you'd get a traceback that would identify the source of the problem.
> The output looks fine, but it ends up with an RC=14:
>
I'll probably get many followups from programmers who take pride in
their skill at coding condition handlers. I don't care. KISS.
For me, "novalue" always results from a coding error. I accept the
system default handling and don't attempt recovery.
A fortiori for "syntax".
In sections of code where I don't believe RC<>0 is possible, I sometimes
wrap "signal on no error", again providing no handler. If Rexx astonishes
me by terminating on an error, I analyze and fix it.
-- gil