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



Hello group:

I am trying to use bsearch & I am stumped on where it determines the 
element number of the found entry in the array.  Below is the code to 
setup the array, I am having problems on the Eval Elem = ..... statement

When I run it, I get an error message Pointer or parameter error message 
id: RNQ0222

TIA
Steve Jones


     D FindIt          PR              *   extproc('bsearch')
     D   key                           *   value
     D   base                          *   value
     D   num                         10U 0 value
     D   size                        10U 0 value
     D   compare                       *   procptr value
     D*
     D myTemplate      DS                  qualified
     D                                     Based(Template)
     D   AAdaitx                     15A
     D   AAdaqqt                     10S 3
     D*
     D Items           DS                  likeds(myTemplate)
     D                                     dim(9999)
     D*
     D p_match         S               *   Inz(*Null)
     D*
     D key             ds                  likeds(myTemplate)
     D*
     D FindItem        Pr            10I 0
     D  Elem1                              likeds(myTemplate)
     D  Elem2                              likeds(myTemplate)
     D*
     D Elem            S              3P 0

                          Do some stuff to get necessary data....

     C                   Eval      Key.AAdaitx = Adaitx
     C*
     C                   Eval      P_match = FindIt (%addr(key) :
     C                             %addr(Items) :
     C                             NumElem :
     C                             %size(myTemplate) :
     C                             %paddr(FindItem) )
     C
     C                   If        P_match = *NULL
     C                   Eval      NumElem = NumElem + 1
     C                   Eval      Items(NumElem).AAdaitx = Adaitx
     C                   Eval      Items(NumElem).AAdaqqt = Adaqqt
     C                   Else
     C                   Eval      Elem = (( P_match - Template)
     C                                    / %Size(MyTemplate)) + 1
     C                   EVAL      Items(Elem).AAdaqqt = 
Items(Elem).AAdaqqt +
     C                                                   Adaqqt
     C                   Endif

     P FindItem        B
     D FindItem        PI            10I 0
     D   elem1                             likeds(myTemplate)
     D   elem2                             likeds(myTemplate)
     C*
     C                   Select
     C                   when      elem1.AAdaitx < elem2.AAdaitx
     C                   return    -1
     C                   when      elem1.AAdaitx > elem2.AAdaitx
     C                   return    1
     C                   other
     C                   return    0
     C                   endsl
     P FindItem        E

As an Amazon Associate we earn from qualifying purchases.

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