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



A couple of quick points here:

1. The concept of CEE4RAGE is crucial.  Being able to register exit point
procedures makes modular programming possible.  CEERTX is another great one.
If you plan on doing high-performance ILE programming, the CEE procedures
are all very important.  Actually, there are some cool ones for date
conversion that I'd like to do some performance testing on in my copious
free time.

2. I like Scott's implementation; it's a standard "lazy initialization"
technique that we use in OO all the time; everybody checks a flag, and if
the flag is not set, they call an init routine.  My primary disagreements
with Scott are nit-picks at best:

2A. You can get around the "caller knowing about me" issue by simply putting
everything in an init routine.  Don't call it OpenFiles, call it Init, and
be done with it.  That way a user can specifically Init it or not.

2B. You might think about a parameter to the Init routine to enable only a
certain function.  This really depends on how large your service programs
are.  If a service program might open a dozen files for one purpose, and
only one or two for another, then a parameterized Init routine might make
sense.

In any case, Scott's got one very good answer for service programs and
activation groups.  This technique is the primary reason to me for using the
*NEW/*CALLER syntax Scott details.

At one point, I thought named activation groups were shared across jobs,
which then made them very attractive, but since that's not the case, I have
a hard time understanding the benefits of a named activation group.  The
housekeeping involved with having to manually shut down the activation group
makes them unwieldy to me.

Joe



> From: Scott Klement
> 
> That's one of many reasons why the "always keep files open" approach
> doesn't always work.  Another one is that when you're writing modular
> software, the caller shouldn't need to know how you're storing your data.

(...)

> 
> The way I do it is to have an "OpenFiles" subprocedure that opens all of
> the files needed by the program.  This routine first opens all of the
> files. Then it registers a CleanUp subprocedure with CEE4RAGE.  Then it
> sets an indicator that says "I'm done opening files".  If the subprocedure
> gets called again, it checks that indicator to see if it's already opened
> the files -- if it has, it simply returns harmlessly.
> 
> Every exported subprocedure in my service program calls the OpenFiles
> routine as it's first line of code.
> 
> When the activation group ends, CEE4RAGE automatically calls my cleanup
> procedure which closes the files.




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.