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



ok. Thank Scott. That is what I means when I replied to Jon with
"To do what you suggested, that means each time the program performs
chain/update/write/read, I've to do remember to do eval-corr to make sure
all version of qualified DS contains the same data."

not as pretty as the tranditional "non result-field ds" version where I use
global fields for all files. Currently, I use the later method (the overlay
method by based pointer). But anyway, I though I ask to make sure there are
no better way that I did not know of.


"Scott Klement" <rpg400-l@xxxxxxxxxxxxxxxx> wrote in message
news:mailman.3167.1282072951.2619.rpg400-l@xxxxxxxxxxxxxxx
On 8/17/2010 1:56 PM, hockchai Lim wrote:
How/what would be the best way to handle above if I prefer to always use
result-field DS when performing file IO opcode?

"best" is a highly subjective term. But here's one way:

if customer# <> 0;
chain (customer#) CUSTL1 myCustL1;
eval-corr myCust = myCustL1;
elseif creditcard# <> 0;
chain (creditcard) CUSTL2 myCustL2;
eval-corr myCust = myCustL2;
elseif ssn <> 0;
chain (ssn) CUSTL3 myCustL3;
eval-corr myCust = myCustL3;
. . .
endif;

ScreenField_CustName = myCust.CUSTNAM;
exfmt mainScreen;
myCust.CustNam = ScreenField_CustName;

chain (CUST#) CUSTL0 tmpCUST;
update CUSTL0 myCust;

This assumes that you declared DSes for each LF like this (where CUSTL0REC
is the record format for CUSTL0, CUSTL1REC is the record format for
CUSTL1, etc)

D MyCust ds likerec(CUSTL0REC:*OUTPUT)
D MyCustL1 ds likerec(CUSTL1REC:*INPUT)
D MyCustL2 ds likerec(CUSTL2REC:*INPUT)
D MyCustL3 ds likerec(CUSTL3REC:*INPUT)
D tmpCUST ds likerec(CUSTL0REC:*INPUT)

Or if you're _sure_ that all LFs will always have the same record format
(which is a dangerous assumption) and that these record formats will
_never_ have input-only or output-only fields in them, then you could
potentially do it this way:

D MyCust ds likerec(CUSTL0REC:*OUTPUT)
D myCustPtr s * inz(%addr(MyCust))
D MyCustL1 ds likerec(CUSTL1REC:*INPUT)
D based(myCustPtr)
D MyCustL2 ds likerec(CUSTL2REC:*INPUT)
D based(myCustPtr)
D MyCustL3 ds likerec(CUSTL3REC:*INPUT)
D based(myCustPtr)
D tmpCust ds likerec(CUSTL0REC:*OUTPUT)

I suppose overlaying in a DS might also work. But, hopefully you get the
idea... anyway... with this, all the DSes occupy the same memory, so
they all access the same data, and you could eliminate the EVAL-CORR in
the code example.

Eval-Corr is definitely safer, though. Is it worth it to save 3 lines of
code, and a millisecond or two of execution time?




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.