Stuff that shakes my confidence in RPG:

I have a data structure which contains an array, with overlaid subfields:

D ds
D conv 70 dim(Size) ascend inz
D oldvalue 35 overlay(conv)
D newvalue 35 overlay(conv:*next)

Size is 1500, but the thing is populated with 794 elements. When I
use %LOOKUP(testvalue:oldvalue), it only returns a nonzero index if
testvalue is one of the first 750 elements in oldvalue.

Then I tried %LOOKUP(testvalue:oldvalue:30), and it returned a nonzero
index only if testvalue is between oldvalue(30) and oldvalue(765),
inclusive. %LOOKUP(testvalue:oldvalue:40) returns nonzero if
testvalue is between oldvalue(40) and oldvalue(770), inclusive. This
pattern continues. It always seems to search only from startindex to
(750 + startindex/2), unless I provide the 4th parameter.

The manual says %LOOKUP searches the entire array when the 4th
parameter is omitted, but that's clearly not happening here. Does
this have something to do with the overlays? I know I have used
simple arrays with more elements and not had this problem.

I'm on V5R2M0, if it matters.

Another finding which surprised (and disappointed) me: The LOOKUP
opcode doesn't seem to make use of sorting. Judging by simple
timings, it always seems to look at every single element of a sorted
array, no matter what indicators I give it. (In contrast, the %LOOKUP
function is much, much faster on a sorted array, as one would expect.)
Yeah, as if we needed any more reasons to avoid using the opcode.

John Y.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 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.