|
On the topic of file usage, is there a way to open/close a file by way
of a pointer?
(Had a hard time writing this next paragraph, but I hope it conveys what
I'm doing and why I'm doing it).
A while back I wrote a srvpgm wherein there were a bunch of
subprocedures. Due to multiple entry points (multiple exported
procedures), they used a variety of different files, but wherein certain
subprocedures used files that may or may not be used by other
procedures. I didn't want to open all the files, only the ones I'll be
using, so I devised an OpenFile procedure and a CloseFile procedure for
the open/close of files.
// Procedure Interface
D OpenFile PI N
D FileName 10A Const
The procedure would then have multiple When statements like the one
below (all w/in the same Select).
// Customer Special Terms file
Select;
When FileName = 'FILEA';
If Not %Open( FileA );
Open FileA;
FileOpened = *On;
Else;
FileOpened = *Off;
EndIf;
EndSl;
Return FileOpened;
Based on the returned indicator (local to the calling procedure) the
procedure would then know if it needed to call the CloseFile procedure.
This would work so much better if I didn't have to hardcode the file
into this OpenFile (or CloseFile) procedure, hence my question of using
a pointer (or some other means). The way it is now, whenever I added a
new file to the module I'd need to add code to the OpenFile and
CloseFile subprocs. Side note: I'm not very knowledgeable on the use of
pointers yet.
Kurt Anderson
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.