Mark,
When using the bif style lookups, please remember that this implementation performs a "binary" search across the ordered array. For a 1000 element array, the half way point is element 500. This is pretty much where the search STARTS.
The problem comes from values "out of sequence" (initialized to 0?) for elements 678 - 1000. When the lookup starts at element 500, if the value being searched is greater than the value at element 500, then it halves the elements on the "greater than" side, looking then at element 750. This element is beyond your last element, and carries the initial value (0) which is definitely LESS than the value you are searching. The lookup ends.
I have accustomed myself to always use the %lookup__( Arg : Array : Start : Elements ) syntax, starting the search at 1 and using my array counter to specify elements. This way, the compiler can check only the elements that you have populated into the array.
Hth,
-Eric DeLong
-----Original Message-----
From: rpg400-l-bounces+edelong=sallybeauty.com@xxxxxxxxxxxx [mailto:rpg400-l-bounces+edelong=sallybeauty.com@xxxxxxxxxxxx] On Behalf Of Mark Walter
Sent: Wednesday, August 31, 2011 10:57 AM
To: RPG programming on the IBM i / System i
Subject: Array Lookup Issue.
I'm having an issue doing a lookup on a dynamically created array. Here is the issue:
I'm creating an array, reallocating the storage one element at a time. I have the array dimensioned as 1000 elements. The array is 30 bytes in length. Then I'm trying to do a %LOOKUPGE against that array. Works fine until I try to search on any data past the 500th element. There are about 677 elements allocated. Any ideas?
Thanks,
Mark.
Mark D. Walter
Business to Business Data Integration Specialist
Certified IBM System I Specialist
Paragon Consulting Services, Inc.
mwalter@xxxxxxxxxxxxxxx
717-764-7909 Ext. (1)26
--
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.