On Wednesday, May 20, 2020 at 10:03:21 PM UTC-4,
robhb...@gmail.com wrote:
> Thanks to Rick McGuire for getting me started on ooRexx. Here's another noob question: I want to handle error conditions in methods.
>
> In TSO REXX there's no such thing as a method, but anywhere in my program I can "call abend <msg>" and an internal Abend routine displays the message and does an Exit 8. Inside an ooRexx method my Abend subroutine apparently isn't visible, so I need another way to signal a bad call.
>
> 1) Easy first question: Is there a way to ~make~ an internal subroutine visible to a method? I'm guessing there is not, but if it is it would probably be simplest.
No, (well, mostly no. You can create internal routines inside the code block of the method, it those are only visible inside that code block). Better would be to create an external routine using ::routine, which will be visibly globally.
>
> 2) Failing that, I can try "return <msg>". But when I try that, the message doesn't show up in RESULT, as I would have expected (nor in RC, which I expected less). Maybe the RETURN statement is only for functions.
This should work. I would need to see an example of what you are really doing in order to suggest what you might be doing wrong.
>
> 3) I tried "exit <msg>", which worked in one situation but not in another: During the init method I used "exit 8", but the result back in the calling program was just RESULT. In another method I used "exit 'No error'", and the result was populated that time. Maybe RESULT just doesn't work with any INIT method? Seems kind of artificial, but what do I know? I can post a short program demo if needed.
Exit from a method just terminates the current code block (basically the same as Return from that context).
>
> 4) Do I have to use a RAISE ERROR statement? I've never had occasion to do that before, but it kind of makes sense.
RAISE SYNTAX would be more appropriate. This will propagate all the way back to the top level unless trapped by a SIGNAL ON SYNTAX. There are even some defined syntax error numbers reserved for USER messages where you can fill in whatever message text you want.
>
> Recommendations gratefully accepted.