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




On 2013-10-23, at 11:46 AM, Robert Rogerson <rrogerson@xxxxxxxxxxx> wrote:

Please correct me if I'm wrong but my understanding is that a file
defined as static in a service program is only opened once on the first
open in the module. If static is not defined then the file must be
manually opened on each call to the module.

Not quite. If you do _not_ declare STATIC then a local file is opened and closed on each call. This permits recursive use of the file within the procedure. If you declare STATIC then the file is opened on first call and remains open "forever" (i.e. until explicitly closed or the Activation Group ends).


So this leads me to believe that there is an advantage to defining
static on a file used in a module in a service program.


It certainly saves opens - but at the expense of losing the recursive use of the file (not a biggie for most people) but manually closing the file can present design issues.


Thanks,

Rob
On 2013-10-23 10:10 AM, Jon Paris wrote:
Well a having local file means that the same file can be used multiple times in the same module - each time with a different cursor.

If that is not desirable then there's not a lot of benefit that I can think of in having local files defined as static vs a global definition.

One option not mentioned in your post that I have found useful is in using the ability to pass a file as a parm. That way the caller gets to "own" a unique cursor while still maintaining the separation of the file handling logic.


On 2013-10-23, at 9:23 AM, Jack Prucha <Jack.Prucha@xxxxxxx> wrote:

We've recently installed 7.1 (jumped over 6.1) and now I have choices. I've created a service program with two subprocedures, each accessing a different file. As was previously my custom, the F specs are global, before the subprocedures, with usropn specified. The subprocedure will be called from batch, interactive and probably a web stored procedure so I don't want a bunch of file opens and closes (could be 1,000s when called from batch) happening automatically. I usually check for %open in the subprocedure and have the calling pgm call one last time to close *all files. Before starting I read a nice article in July, 2013 IBM Systems Mag by Jon and Susan (Thx!) that explained new methods of global and local file definitions and controlling opening and closing files.

Now I'm confused. Are there real advantages to local files defined perhaps with static over global files with usropn controlling opens/closes? Or is just a preference?

TIA
Jack

This email, including any documents, files, or previous email messages attached to it, has been sent from an email account of College Foundation Inc., (CFI) and may contain confidential, proprietary, or legally privileged information belonging to CFI. If you are not the intended recipient, any dissemination, distribution, or copying of this email or its attachments is strictly prohibited. If you have received this email in error, please immediately notify the sender by email and destroy the original email and any attachments.
--
This is the RPG programming on the IBM i (AS/400 and 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.

Jon Paris

www.partner400.com
www.SystemiDeveloper.com





--
This is the RPG programming on the IBM i (AS/400 and 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.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com





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.