+ Reply to Thread
Results 1 to 4 of 4

Thread: LOOKUP for a Multiple Occurance Data Structure

  1. #1
    Guest.Visitor Guest

    Default LOOKUP for a Multiple Occurance Data Structure

    Use bsearch() in the C run-time library. (A web search should turn up a few examples of how to call it from RPG.) Cheers! Hans

  2. #2

    Default LOOKUP for a Multiple Occurance Data Structure

    Michael Soucy wrote: > > Does anyone know of an API that will allow you to "search" a multiple occurance data structure in the same way you can lookup a table or array in RPG? bsearch() is probably the best solution, but you could also define a based array over the data structure, and do the lookup on the array. Untested: D mods ds occurs(10) D sub1 10a D sub2 5p 0 D mods_arr s like(mods) D dim(%elem(mods)) D based(pMods) D pMods s * inz(%addr(mods)) D search ds likeds(mods) search.sub1 = whatever; search.sub2 = whatever; index = %lookup (search : mods_arr); If not on V5R1, you would have to define the "search" structure with its own subfields, but it would be basically the same. D search ds D srch_sub1 like(sub1) D srch_sub2 like(sub2) C eval srch_sub1 = whatever C eval srch_sub2 = whatever C eval i = 1 C search lookup mods_arr(i)

  3. #3

    Default LOOKUP for a Multiple Occurance Data Structure

    Does anyone know of an API that will allow you to "search" a multiple occurance data structure in the same way you can lookup a table or array in RPG?

  4. #4

    Default LOOKUP for a Multiple Occurance Data Structure

    I think I'll try the bsearch c-function. I found a whole write-up about it in the IBM Redbook "Who knew you could do that with RPGIV". Thanks again for your help.

+ Reply to Thread

Similar Threads

  1. %Lookup and Qualified Data Structure
    By Guest.Visitor in forum RPG
    Replies: 0
    Last Post: 06-27-2006, 11:29 AM
  2. Replies: 1
    Last Post: 08-26-2003, 05:48 AM
  3. Multiple occurence data structure
    By Andy26 in forum RPG
    Replies: 2
    Last Post: 07-30-2003, 04:45 AM
  4. Multiple occurance data structure in Debug
    By Guest.Visitor in forum General
    Replies: 3
    Last Post: 02-07-2003, 04:43 PM
  5. Sorting a Multiple Occurance Data Structure
    By Guest.Visitor in forum Programming
    Replies: 8
    Last Post: 10-06-2000, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts