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



Jon's example is the format I use for array DS.  I was about to try out
Charles' example, but I'll have to do that later....  

FWIW, I sometimes extend this just a bit....  I add the Inz(*All'9') so that
any unassigned elements will automatically float to the end of the dataset
when sorting (ascend).  Note that numeric elements should always be declared
as zoned for this INZ to work correctly.  The addition of the counter field
to the DS makes it more convenient to pass the entire DS as parameter data
to a subprocedure.  All attributes needed to constrain the search of this
array are self-contained in the DS.

   d myDS            ds                  qualified
   d  myArrayCnt                    5u 0 Inz(0)
   d  myArray                            dim(800) Inz(*All'9') 
   d   fld1                        10a   overlay(myArray)
   d   fld2                        10s 0 overlay(myArray: *next)
   d   fldxdesc                    20a   overlay(myArray: *next)
   d   mySort                      30a   overlay(myArray: *next)

I always use the %Lookup bif, since it allows the number of elements to
search to be declared, keeping me from searching through the unused
elements...  

Another easy technique:  This is used when you need to sort on more than one
column (ie. if fld1 is postal code, and fldxdesc is customer name, sort the
data in customer name, postal code order).  Populate mySort = fldxdesc +
fld1, then sorta mySort.  If the user wants to change the sort order (Fkey)
to postalcode/name order, then spin through the populated array elements,
reload mySort in the new format, and sort.

Clearly, the worst aspect of this approach is the limited size of the
dataset, as all this data must be able to exist in 64k bytes.  As you say,
there are ways around these limits in RPG, but if I get to those, I'd be
just as well off using C runtime to manage the array data....

Eric DeLong
Sally Beauty Company
MIS-Project Manager (BSG)
940-297-2863 or ext. 1863


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.