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



I think this would do what Booth wants:
Jeff,

I'm assuming that Booth is keeping track of how many elements there are in
his subfile

If you use RTNCSRLOC in the display file, e.g.:

A RTNCSRLOC(&CSRFMT &CSRFLD)
A CSRFMT 10A H
A CSRFLD 10A H

then you'd have this in the RPG (in addition to Jeff's data-structure)

D ElemNbr S 10I 0
D SortField S 10A
D SortSeq S 10I 0 Inz(1)
D SortFieldSave S 10A

// Set the sort field from the column clicked
SortField = CSRFLD;

// If the user has re-clicked the same column, swap the sequence
If SortField = SortFieldSave;
SortSeq = -SortSeq;
endif;

// Save the sort column
SortFieldSave = SortField;

// Sort the array
qsort( %addr(Scrn_Field) : ElemNbr : %size( Scrn_Field ) : sortprocptr );

// Now redisplay the subfile


and in sortprocptr, yuo'd have this:

P sortprocptr B Export
D PI 10I 0
D Elem1ptr * Value
D Elem2ptr * Value

D Elem1 DS Likeds(Scrn_Field) Based(Elem1ptr)
D Elem2 DS Likeds(Scrn_Field) Based(Elem2ptr)
D rtncde S 10I 0 Inz

select;
when SortField = 'PRES';
if Elem1.President < Elem2.President;
rtncde = -1
if Elem1.President = Elem2.President;
rtncde = 1;
if Elem1.President = Elem2.President;
rtncde = 0;
when SortField = 'COLOR';
if Elem1.Color < Elem2.Color;
rtncde = -1
if Elem1.Color = Elem2.Color;
rtncde = 1;
if Elem1.Color = Elem2.Color;
rtncde = 0;
...and so on...
endsl;

return rtncde * SortSeq;



On Wed, Oct 22, 2008 at 8:47 AM, <jdavis@xxxxxxxx> wrote:

The only thing about my method is that it also sorts the rows with the
columns, in the example only the column was effected.

Would qsort only sort the subarray in the DS or would it sort the whole DS
like SORTA?


Jeff Davis

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.