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



Faced with the same problem I did this:

D* Set the subfile for sorting - ascending & descending
D                 ds      
D SflArrayUp              630    dim(200)
D  SortUp                  30    overlay(SflArrayUp)
D  DataUp                 600    overlay(SflArrayUp:*next)
D SflArrayDown            630    dim(200) Descend 
D  SortDown                30    overlay(SflArrayDown)
D  DataDown               600    overlay(SflArrayDown:*next)
 
where the sortup & sortdown fields are filled with the user selected
elements for sorting.  The field dataup & datadown are like the record's
data structure.  I sorta on both  arrays so I can display either ascending
or descending without reloading the data structure.
 
 
---------------------------------------------------------
Booth Martin   http://www.MartinVT.com
Booth@xxxxxxxxxxxx
---------------------------------------------------------
 
-------Original Message-------
 
From: RPG programming on the AS400 / iSeries
Date: 01/16/04 19:01:30
To: rpg400-l@xxxxxxxxxxxx
Subject: Sort of a Data Structure Array... Idea
 
I have a situation where I am using a data structure array, like this:
 
     D DispItems       DS                  Qualified Dim(5000)
     D  Insurance                     5S 0 Inz(0)
     D  Family                        9P 0 Inz(0)
     D  Member                        2S 0 Inz(0)
     D  Claim                         4P 0 Inz(0)
     D  Assigned                       D   Inz(*Loval)
 
After gathering and populating the array, I must show a sub-file for
user-selection, summarizing the elements in the array by the Insurance
field.  I wanted a way to sort the array (SORTA), but being a data
structure, that won't work.  So I started reading the sorc guide on qsort,
then a better idea occurred to me:
 
Set up a simple array, like this:
 
     D DispArray       S             25A   Dim(5000) DESCEND
 
Then, remove the 'Dim(5000)' from the data structure, and use it like a
model to populate as I need to assign/retrieve data elements out of the
array.  Basically, as I am stepping through the array, I EVAL the selected
array element into the data structure 'model', then address each field of
the data structure.  Once updated, I EVAL the data structure back into the
array element.
 
So SORTA works on the DispArray array now.  In your opinion, is this a good
idea?  Is this more or less efficient than using qsort?
 
Tony Carolla
MedAmerica Billing Services, Inc.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.