Bill Giannelli asked:

>I also have a Rexx routine that has "call code 0" and call code 0 100"

>which seems to branch to a routine "code" for error handling?

>how are the 0 and 100 values processed?

 

Lionel (correctly, of course) noted that there's nothing special about this. 
I'd add that this is a semi-hack to allow passing parameters to the error 
handler. For example, you might have code like this:

 

'some command'

if rc <> 0 then signal SomeCommandFailed

 

'another command a'

if rc <> 0 then call AnotherCommandFailed 'a'

 

 

'another command b'

if rc <> 0 then call AnotherCommandFailed 'b'

 

...

 

SomeCommandFailed: /* Reached via SIGNAL */

say 'The SOME command failed'

exit rc

 

AnotherCommandFailed: /* Reached via CALL */

arg why

say 'The ANOTHER command failed on the' why 'call.'

exit rc

 

This is a pretty hokey example, obviously, but I've seen both techniques used a 
lot. The SomeCommandFailed handler could also be CALLed with no parameters, but 
one of the advantages of SIGNAL is that because it's *not* a CALL and you know 
it's not going to RETURN, someone new (or you, six days/weeks/months/years 
later) reading the mainline can draw some conclusions from it in trying to 
understand that mainline. I'm a strong advocate of using it for error handlers 
that aren't going to return for this reason. It's also more efficient, since 
it's not saving state over the call, although these days we mostly don't worry 
about that so much.

 

This makes SIGNAL kind of a Rexx idiom, because it's not really a GOTO, 
although it plays one on TV. Just don't do this please:

 

signal SomeLabel

ReturnFromSomeLabel:

...

 

SomeLabel:

<code>

signal ReturnFromSomeLabel

 

Now that would be ugly. And to a Rexx programmer, Just Plain Wrong.

 

.phsiii

 

P.S. I'd also never call a subroutine CODE simply because it's too common a 
word-too hard to find references to it. Use names like the above!

 


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

Reply via email to