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



Hi Justin,

> Would comparing fields from one file to another be the only reason to
> read an external file into a data structure?  If not, could someone give
>   some other examples on why you would do this.
>

A few things come to mind:

a) It's faster.  When reading into a data structure, the system can block
copy the whole record from the file to the DS, since the fields are
guaranteed to be contiguous in memory.  With standard I/O, each field has
to be handled separately.  (Not that this is a big deal)

b) You can have more than one record loaded into memory at the same time.
For example, a client's record in the customer master file may contain the
account# of the client's parent company.  If you needed to work with both
the parent's record and the client's record at the same time, you could
load them into separate data structures.  (One called "parent" and one
called "client") without the need for two separate F-specs and overrides
and all that stuff.

c) You might want to see if a record is changed.  For example if you're
writing a maintenance program where a record is loaded, displayed on the
screen, and then updated...  Since you probably don't want to hold a lock
on the record while this is happening, you'd save a copy of the record
from when you loaded it, and you'd load another copy when you're ready to
update.  If those have changed, warn the user that someone else has
changed the record, and that saving his changes might result in data loss.

Yes, there are workarounds with things like prefix and field renaming and
overrides that allow you to do this without reading into data structures
or using LIKEREC. But now you can do it this way, and you might like it
better...  <shrug>


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.