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



James,

One final solution:

If you're simply retrieving this data (i.e. you're not actually updating
it), you can do the following:

1. Define a 'generic' file as internally defined with no key and with a
record length as long as the longest possible record length of any of the
files you would access. It doesn't need any keys defined.

2. Define an array with each entry being a long string (as long as the
longest record length)

3. Define a set of dummy data-structures the same as the various possible
record layouts - defined as BASED if you're concerned about space)

4. Load the entire file into the array (first time round)

5. Use qsort() and bsearch() to get the record you want then overlay the
array element with the required data-structure.

Depending on the amount of work (CHAIN's, that is) you're doing, this might
even give better performance than other methods. It's pretty generic, so you
could add new file definitions as you see fit. Alternatively, you could
simply put it all in a nice neat procedure in a service program, where the
procedure is passed a file name and key and returns the array element as a
character string - that way, there's absolutely no hard-coding in the
procedure - you only need to define whichever of the record format
data-structures that you need in the calling program, e.g.

/free
  FileABCRecord = GetFileRecord( 'FileABC' : Key1 : Key2 : Key3 );
/end-free

I have LOTS of examples of this sort of thing in both RPG, fixed-fornmat
RPGLE and free-format RPGLE if you want.

Just a thought...

Rory

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.