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