× 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.



Hi Tony,

It is the ASCEND that is causing the problem. Try the following example:-

D Data            DS
D  Arr                           3    Dim(10)
D                                     Ascend
D   Load                         9    Inz('ABCABDABE')
D                                     Overlay(Data)

D Pos             S              5I 0

 /Free
      Pos = %LookUp('ABE':Arr);
      Dsply Pos;
      Pos = %LookUp('ABC':Arr);
      Dsply Pos;
      *InLR = *On;
 /End-Free

In both cases Pos will be 0. Remove the ASCEND keyword and they work fine.

Alternatively, use the two optional parameters to specify the starting
element and number of elements to search, as in:

      Pos = %LookUp('ABE':Arr:1:3);

The reason is that, unlike the LOOKUP operation, %LookUp does a binary chop
to find the element.

BTW the ASCEND keyword is required if you are using any of the other
%LOOKUPxx BIFs.

HTH

Paul Tuohy

----- Original Message -----
From: <CarollaT@xxxxxxxxxxxxxx>
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, July 01, 2004 12:42 AM
Subject: Reasons for %Lookup failure


> I am having a problem with the %Lookup BIF.  I am performing a %Lookup on
an
> array that has the value in it (I have debugged), and yet the %Lookup does
> not produce the index number of the array element.
>
> The array is very simple:
> D SiteCursor      S              3A   Inz(*Blanks)
> D                                     Dim(300)
> D                                     Ascend
>
> I read through a file (in Key order, the key being the value that will
fill
> in the SiteCursor elements), and populate each element in the array with
the
> site ID value (3 Alpha).  I am also populating a similar element of a data
> structure array, which will hold numerics.
>
> Once populated, I read through an accounts file, and for each record, I
> %lookup the site ID in the SiteCursor array:
>
> ElemNumber=%Lookup(Fmacro:SiteCursor);
>
>
> I then use the ElemNumber index value to add up dollar amounts from the
> accounts file, in the other data structure array:
>
> Sitesum(ElemNumber).SumChgs += Fmcrch;
>
>
> In debugging, for some reason, the %Lookup never works.  I have verified
> that the array contains the element being looked up, but it fails to place
> any value in the ElemNumber variable.  I know the values are in order in
the
> SiteCursor array, so I don't do a SortA, because this would sort all of
the
> blanks to the top.  Does a SortA need to be run for %Lookup to work?
>
>
>
> Tony Carolla
> MedAmerica Billing Services, Inc.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.