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



As you can see, I didn't use the same-named fields that Booth used, because
I basically cut 'n' pasted my own code in there.

If you wanted, you could hold the buffer positions of the various fields in
the DS in a compile-time array and then simply use memcmp() or memicmp() in
sortproc. That would *greatly* simplify the code in sortproc()...

So the CTDATA array definition is as follows:

D FieldArr DS Qualified
D Array Dim(5)
D Name 10A Overlay(Array)
D Start 3S 0 Overlay(Array:*Next)
D Length 3S 0 Overlay(Array:*Next)

and the data in it is as follows:

** CTDATA
PRES 001025
COLOR 026010
NUMBER 036006
OCEAN 042020
CONTINENT 062025

and here's the new, simpler, sortproc():

P sortproc B
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 x S 10I 0 Inz
D rtncde S 10I 0 Inz

/free

x = %lookup( SortField : FieldArr.Name : 1 : %elem( FieldArr.Array ) );
if x > 0;
rtncde = memcmp( Elem1ptr + FieldArr.Start(x) - 1 :
Elem2ptr + FieldArr.Start(x) - 1 :
FieldArr.Length(x) );
return ( rtncde * SortSeq );
endif;

dsply 'Field ' + %trim( SortField ) + ' not found!';
return 0;

/end-free

P B

Rory

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.