Dennis,

This problem has piqued my curiosity, as LOOKUP is a opcode that I have not
used in a (very) long time. I found this in a Bob Cozzi article (
http://systeminetwork.com/article/built-functions-you-might-not-be-using-fully
)
:

"One thing that needs to be pointed out is that the %LOOKUP built-in
function performs a different routine to search the array than does the
legacy LOOKUP opcode. So there is a chance you could get a different result
if you blindly convert LOOKUP opcodes to %LOOKUP built-in functions.

LOOKUP generated a subroutine based on the Resulting Indicators and
performed a sort of linear scan to locate matching elements, whereas %LOOKUP
uses a binary search routine to find the elements. This means that if the
data is not sequenced, %LOOKUP could fail to locate the elements even if
they exist."

I wonder if David found a solution to his problem?

Regards,


Luis Rodriguez
IBM Certified Systems Expert — eServer i5 iSeries
--



On Thu, Dec 16, 2010 at 1:59 PM, Dennis Lovelady <iseries@xxxxxxxxxxxx>wrote:

Yes. So that would be relevant if David were using %TLOOKUPxx. But he's
not. He's using the %TLOOKUP, which does not use binary search.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"A fanatic is one who can't change his mind and won't change the subject."
-- Winston Churchill


It looks to me like %TLOOKUPxx uses a binary search, as %lookupxx does.

"Since a binary search is used by the %LOOKUPxx built-in functions for
a
sequenced array, and the correct function of a binary search depends on
the data being in order, the search may only look at a few elements of
the array. When the array is out of order, the result of a binary
search
is unpredictable. "


On 12/16/2010 10:23 AM, Dennis Lovelady wrote:
The manual refers to both kinds of lookups. The kind that David is
using is
not of the %TLOOKUPxx set, the nearest I can determine. The %TLOOKUP
BIF
works by comparing each value starting with 1 and ending when a match
is
found or the end of the table is reached. Sequence is immaterial.
Or at
least that's the way it was the first 35 years or so of the language.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"A diplomat is a person who can tell you to go to hell in such a way
that
you actually look forward to the trip."
-- Caskie Stinnett

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.