× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I just RPG doesn't have something similar to exit(0) in C.

thanks.

-----Original Message-----
From: Scott Klement [mailto:klemscot@xxxxxxxxxxxx]
Sent: Wednesday, June 18, 2003 12:18 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: exit the program from the subprocedure


> Before:
> I used to have a wrapup subroutine that do some clean up, set on the
> *inlr and then do a return to exit the program.
> After:
> If I convert the above subrotine to a subprocedure, the return will
> simple return control back to the procedure that call it.  Another word,
> it does not exit the program as before.

Subroutines should not be able to end the program, except in the case of
a "fatal error."  It just seems like a bad idea...   subroutines are
intended to help make code more reusable.   In one prorgram, the routine
that calls your subproc may want the program to end, in another one, it
may want to do something else afterwards.   The caller should be in
control of that, not the subprocedure!

Instead, just have your main procedure do this:

     c                   callp     cleanup
     c                   return

or

     c                   callp    cleanup(endflag)
     c                   if       endflag = *on
     c                   return
     c                   endif

It doesn't seem like it's worth ruining code reusability just to save one
line of code in your mainline.

On the other hand, if you're handlign a fatal error, that's a whole
different situation.   In that case, you want the program to "crash"
immediately.   That's the situation where you want to send an escape
message back to an earlier call stack entry.
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.