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



But I have one question. If we open all the files used by various
procedures in the module, when only one procedure is used by the caller,
What is the need of defining the file as usropn, Doesn't the OS do it for us
when we declare a file with out usropn in a NoMain module?

RPG will automatically open the files for you, yes. (It's code that's either generated by RPG, or is part of the RPG runtime that does this, not the OS.)

I guess I like my programs to control how files are opened, in case I want to execute an OVRDBF or use EXTNAME/EXTMBR.

Plus, I can do other things in the init and done routines besides open files. I can allocate memory, or create temporary objects, or anything else that needs to be done when my service program starts.

So, I like to establish these routines in every service program. Even if I don't need the extra flexibility that they offer, it's easier to code them now and have everything working properly than it is to try to retrofit them later if I need them.

Another thing that I could've done, instead of closing each file individually with "if %open / close / endif" I could've just said "Close *ALL" and it'd close every file that's open. But, I like to have code the closes them explicitly... I like it to be something that's absolutely clear in my code.

But, this is all a matter of style, and style is a matter of opinion. If you prefer to let RPG do the work for you, you do have that option.


I know we cannot code CEE4RAGE, and depend on the OS to close all ODP's when
activation group ends. What are the other advantages?

Just that you have a routine where you can put "first time run" code. (Similar to an *INZSR) and a routine where you can put "before closing" code. You can use that to do some special setup if you want to. I like having that functionality available.


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.