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


  • Subject: Re: bsearch on partial array elements
  • From: Jon.Paris@xxxxxxxxxx
  • Date: Thu, 13 Jan 2000 14:02:10 -0500



 >> Any ideas how I can get round this without creating more arrays ?

 As you know bsearch passes two pointers to your compare procedure - one to the
search key and one to the candidate field.  These pointers can be used to base
_anything_ a field, an array, or a DS.  Instead of using the pointer to base a
field (as I suspect you are now) you could base a DS which defined two
subfields.  The being your comparison field and the second the balance of the
original entry.  However, if you do not need to refer to the data in the latter
part of the field at all then the answer is even simpler - just define the based
fields as being smaller !!!

One word of warning - if there are multiple entries with the same value in the
part of the field you are comparing against, bsearch will not necessarily return
the first in the sequence as LOOKUP would on a similarly sorted array - it is up
to you to walk back through the array to find the first one if you need it.


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


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.