|
Chamara,
The fact that removing ASCEND changes the outcome should give you a clue.
With the ASCEND keyword you promise the compiler that the entries in the
array will be in ascending order, so the compiler can use a binary search.
Initially all entries in the array are blank; when you fill entry 1 the
order is broken. The manual has a special paragraph about this (page 553
in 7.1).
You have several options:
- Don't specify ASCEND - the search will be somewhat slower
- Keep track of how many entries in the array are filled and give that
number als fourth parameter to %lookup
- (For completeness' sake:) Initialize all entries with *HIVAL
Joep Beckeringh
%Lookup ClarificationI
Chamara Withanachchi
Hi,
I cannot recall this earlier, I'm in a 7.1 box with latest PTFs applied,
have done a %Lookup operation to a array as bellow--
D poArr S 6 DIM(9999) ASCEND
C Eval P = 1
C Eval P = %LookUp(Arr1(Idx1) : poArr : P)
When I see the array in Debug mode I can see the search criteria is in
the poArr array, but P become 0 after the %Lookup even though values are
in poArr array
When I removed the ASCEND keyword, P became the element no of the poArr
Array, (%Lookup Success) any idea What I'm I missing here?
--
Regards,
Chamara Withanachchi
This is the RPG programming on the IBM i (AS/400 and iSeries) (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 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 copyright@midrange.com.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.