×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




And besides, Hans, by the time people start using V5.3 you'll have something
like a %SORT() built-in or enhancements to the SORT opcode ready to go. :)

And yes I am happy the SORTA opcode works with the Alternate Calc spec.
<vbg>


Bob Cozzi
Cozzi Consulting
www.rpgiv.com


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Hans Boldt
Sent: Tuesday, December 09, 2003 8:06 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: SORTA and Data Structure Arrays

Bob cozzi wrote:

> Is this a "what's wrong with this picture" problem?  
> Sorry, couldn't resist. <g>
> 
> To answer your question: SortA does not and probably will never sort data
> structures.
> The new %SORT() built-in function will sort data structure arrays, however
> that won't be out until (at least) V5.3. The cool thing about %SORT() is
> that IBM may be able to include the data structure subfield sort
> capabilities, and I'm hoping they will, so you could do something like
this:
>   %sort(myDS : 'A' : NumElems : 'QTYORD')
> 
> Where myDS is the data structure array or array name; 'A' is either 'A' or
> 'D' for Ascending or Descending; NumElems is the max number of elements to
> sort, and 'QTYORD' represents the data structure subfield name that will
be
> used to sort the data structure. 
> ...  

Bob: You're dreaming. There's no %SORT() built-in function in V5R3.

What V5R3 *will* have is a minor enhancement to opcode SORTA, which will 
allow a fully-qualified name as the Extended-Factor-2 argument. 
(Currently, only an old-style Factor-2 argument is allowed.) Thus, you 
can sort array subfields of nested qualified data structures. For example:

       SORTA DS(I).SUBF(J).ARRAY;

In addition, you will also be able to sort partial arrays using the new 
%SUBARR() built-in. For example, to sort just the first 10 elements of 
an array, you could code:

       SORTA %SUBARR(ARRAY:1:10);

(Bob, you'll be happy to hear that these will work in fixed-form calcs, 
as well as free-form! ;-) )

I agree 110% that there's a need for SORTA (and also %LOOKUP) to handle 
array data structures. But first we have to decide on a syntax for 
specifying which subfield to use as the sort key. It may happen 
eventually, but not for V5R3.

Cheers! Hans


_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




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