× 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.



"Bramley, Stu" wrote:
> ...
> I don't really like the solution of the 'control' module that contains the
> public closedown procedure calling private closedown procedures in all of
> the other modules. This is because it means that the code in the control
> module has to know about the physical implementation of the other modules
> that make up the service program. I can't think of an alternative solution
> at the moment though. It seems bizarre that there is no apparent
> straightforward way of doing this.
> 

The most straightforward way to do this is to have the entire
application run in the same activation group.  When you want to shut the
application down, you end the activation group.  If the application runs
in the *NEW activation group (with all the subprograms/srvpgms in
*caller), the activation group ends automatically when the application
ends.)  
Maybe your V5R1 version was running in *NEW; in that case your CLOSE
*ALL would have only closed some files, but they would all have been
closed after the program ended making it seem like the CLOSE *ALL did
the trick.

But I think having an init and cleanup procedure in every module is a
good practice, even if they don't currently do anything.  There are a
couple of basic ways to control them:

1. Every procedure checks a flag to see if init has been done, and if
not, calls the init procedure.  The init procedure registers the cleanup
procedure with some central procedure that will call all registered
routines at cleanup time.  (This registration just has to take a
procedure pointer, add it to an array, and for cleanup, call all the
procedure pointers in the array.)

2. When a new module is added to an application, you add calls to its
init and cleanup procedures from your main init/cleanup processing.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.