× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



JMoore=UWyKbL8KXUw@public.gmane.org wrote:
Has anyone noticed any strange results with using the %LookUp Built In
Function under V5R1?  I have an  array (defined as ErrorCodes      S
1    Dim(11) Inz Ascend) which I am loading with various codes for error
reporting purposes.  If the array is empty no errors were found on the
input record, and I want to process that record.
I originally used the following logic to determine if the ErrorCodes array
was empty...

If          %LookUpGt(' ':ErrorCodes) > 0
Write       Error
Eval        ErrorCount = ErrorCount + 1
EndIf

I found that sometimes this logic would work and other times it would
not...

I tried changing the code as follows:

Eval        Index = %LookUpGt(' ':ErrorCodes)

If          Index > 0
Write       Error
Eval        ErrorCount = ErrorCount + 1
EndIf

Again, sometimes this worked, sometimes it didn't...

I also tried changing the BIF like so %LookUpGt(' ':ErrorCodes:1:11) to
start the search from the 1st array element through the 11th.  It didn't
solve my problem...

I have even stepped through a debug session and watched the array being
loaded, yet an error report record was never written...  In the first
example I stepped from the If to the EndIf.  In the second example Index
was zero...

Is it just my code or does the %LookUp BIF have a "bug" in it???
I assume you have an "ErrorCodes" array initially with all blank
elements, and then you are adding error codes at some point by
looking for available blank elements. Since you're using %LOOKUPGT,
you've defined the array as sorted in some sequence using either
ASCEND or DESCEND. Thus, you are making a promise to the compiler
that the array is sorted in a particular order. Are you ensuring
that the data in the array is always in the declared sequence? If
the data is NOT in the promised sequence, it is very likely that the
lookup will fail to find the element you're looking for.

Cheers!  Hans





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.