|
Why not something like this: C clear RecordFirmat C Key3 chain file C if not %found C exsr NotFoundSR C else * at this point the record fields have values. C key2 chain file C if %found C key1 chain file C endif c endif c endif That is clear, fast, and accurate. Shannon O'Donnell wrote:
I posed this question on MCPressOnline the other day but I would like to get more opinions on it so I'll post it here too. A shop-standard hangs in the balance.Assume that you have an RPG program that has logic such that you need to first see if some data is in a file, based on a key, and then if so, you do something with that data.Further assume that this file has a complex key with three fields.The program logic is such that you check the maximum number of keys for a match down to the minimum number of keysLike this:Key1 Klist Kfld Fld1 Kfld Fld2 Kfld Fld3Key2 Klist Kfld Fld1 Kfld Fld2Key3 Klist Kfld Fld1Which one of these logic blocks is most efficient?Key1 Setll file If %FOUND(file) Key1 READE file Use Fields Else Key2 Setll File If %FOUND(file) Key2 Use Fields Else Key3 Setll File If %FOUND(file) Key3 READE file Endif Endif EndifOR....KEY1 Chain file If %FOUND(file) Use fields Else KEY2 Chain file If %FOUND(file) Use Fields Else KEY3 Chain file If %FOUND(file) Use Fields Endif Endif EndifMy opinion is that the CHAIN is more efficient from both a coding/maintenance standpoint and from an I/O standpoint, but I'm open to opinions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.