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



Tony,

Nah, I'd put the file into it's own module & service program with separate
getter and setter functions for each field.  Get the file and data structure
definitions out of the program.  Everything encapsulated in the module.
Have functions & procedures in the service program to navigate and housekeep
the file.  Use getters and setters to access fields on the file.  Keeps the
main program as simple as possible.  Using an employee file example with
Ali's style of a read procedure the main program would be coded as:

DoW ReadNextEmployee( SSN );
 Name = GetName( SSN );
 State = GetState( SSN );
EndDo;

With ReadNextEmployee, GetName, GetState & other procedures in the employee
service program.

The getters also function as chained reads with some under the cover calls
to a ReadEmployee( SSN ) subprocedure.  They can be used like:

DoW ReadNextOtherFile( OtherFileKey );
  SSN = GetSSN( OtherFileKey ); // here's a getter from the OtherFile
service program
  Name = GetName( SSN );  // Name is blank if SSN is not found
  State = GetState( SSN );     // State is blank if SSN is not found
EndDo;

All the procedures in the module are pretty simple.  Don't usually need to
look at the module source to use it.

The module can be modified without effecting the programs that use it.
Maybe the module to start using SQL statements instead of RPG opcodes to
access the file.  Maybe the module will call Java methods on a true employee
object.  No problem.

Personally I don't use Ali's style of a read procedure.  I'd rather have two
procedures.  One reads the next employee.  The other tests for end of the
employee file.

Paul

-- 
Paul Morgan
Senior Programmer Analyst - Retail
J. Jill Group
100 Birch Pond Drive, PO Box 2009
Tilton, NH 03276-2009
Phone: (603) 266-2117
Fax:   (603) 266-2333
"Tony Carolla"  wrote

> So each file would have it's own subprocedure for reading?  Beautiful.
>  Bulky, but beautiful.  And if you wanted to read into a DS, then
> would you define the DS in the subproc and the main, and return the
> DS?  Or would you forego encapsulation and access the Global DS?  And
> then, while maintaining this code, you might find yourself scrolling
> all the way down to the bottom/back to the top,etc.
>
> In my opinion, this overcomplicates the operation.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.