|
Jon Erickson wrote: > I'm attempting to separate a common subroutine into its own module, (MOD1) > to be bound and callable from other programs/modules. > > The Module opens File1 for input. I'd like to be able to call this module > repeatably without the file initialization overhead, yet not have to call > the module an additional time just to seton LR to close the file. > > Any insight appreciated.. Is there a specific reason you decided against the extra call to close the file? It seems to me that if the decision to close the file is made by MOD1's caller(s) then the caller(s) will need to know internal details of how MOD1 works (did MOD1 open the file successfully?) Moving closer to Utopia, MOD1 should have at least 3 procedures that are Public: Open, OperateOnFILE1Data, Close. That way you can bundle the data and the code needed to manipulate it all in one place. The ideal environment would have a separate procedure for each operation you need performed on FILE1's data: Read, Write, Update, Position, etc. instead of a global OperateOnFILE1Data. This way, each procedure does one thing and one thing well. Not all of these procedures need to be public: if you need to total up the A/R for an account, you may have a public GetTotalAR(CustomerID: ARTotal) that calls the internal Read procedure. This way you can separate the actual I/O from the processing. If you decide to use ODBC or SQL tomorrow, you just change the I/O procedure and the rest of MOD1 is ready "as-is." That's my insight anyway. And it's worth every penny you paid for it! :-) Buck Calabro Aptis, Albany, NY +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.