|
You might be able to create procedures for each file and use a pointer to the procedures to mimic what you want. I'm not sure that would be any better from a complexity point of view though. Especially if you aren't experienced with pointers. Rick -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Kurt Anderson Sent: Friday, January 07, 2005 1:05 PM To: RPG programming on the AS400 / iSeries Subject: Open/Close of Files 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 Privileged and Confidential. This e-mail, and any attachments there to, is intended only for use by the addressee(s) named herein and may contain legally privileged or confidential information. If you have received this e-mail in error, please notify me immediately by a return e-mail and delete this e-mail. You are hereby notified that any dissemination, distribution or copying of this e-mail and/or any attachments thereto, is strictly prohibited.
As an Amazon Associate we earn from qualifying purchases.
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.