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



Opening a file is a very expensive operation. (One of the most expensive ones that I use on a regular basis, in fact.)

So I guess the real question is: How often do you expect your procedure to be called? Are there programs (or can you envision a scenario) that need to call your procedure over and over in a loop? If so, I'd say that opening and closing the file each time is a bad idea. It's suicide to performance.

In my experience, the most common (and probably best) practice is to open the file once, and then just leave it open until the activation group or job ends. Some people provide additional routines to allow the caller to explicitly re-open or re-close the files without having to end the activation group.

Are there circumstances where it makes sense to open the file on every call to the procedure? Absolutely. It really depends on what you're doing! But, in 95% of the cases, you want to leave the file to improve the performance of subsequent calls.


Mike wrote:
Maybe I worded it wrong. "Best Practice" maybe?

It looks like others do the same thing open and close the file on every
call. I didn't know if I could or should keep the file open while the main
program is running. This is in a module by the way.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.