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



Booth

I'm going to take a wild shot and see if I remember what Paul Tuohy says -

1. Dimension the data structure - give it a length equal to the sum of the lengths of those 7 fields.
2. Take the dim() off each subfield
3. Use OVERLAY on each subfield, overlaying the DS itself, with the first subfield overlaying at position 1 and all the remaining ones using *NEXT

If we assume the fields are all 10 characters long, something like this -

D ArSfl ds 70a qualified dim(300)
D ArField1 like(Field1) overlay(AfSfl : 1)
D ArField2 like(Field2) overlay(AfSfl : *next)
D ArField3 like(Field3) overlay(AfSfl : *next)
D ArField4 like(Field4) overlay(AfSfl : *next)
D ArField5 like(Field5) overlay(AfSfl : *next)
D ArField6 like(Field6) overlay(AfSfl : *next)
D ArField7 like(Field7) overlay(ArSfl : *next)

Now when you do the sort you describe, do it just as you have it - the subfields end up being arrays, would you believe, and sorting one takes all the rest with it.

I was looking up this very thing and found this article - http://www.mcpressonline.com/programming/rpg/those-weird-and-wonderful-arrays.html

By the way, you should look at using the SortA in free-form - you can specify the starting and ending elements to be sorted. Maybe the opcode did that too, just haven't checked that out.

That article has stuff on doing this for filling a subfile based on user choices.

HTH
Vern

On 8/13/2010 4:10 PM, Booth Martin wrote:
I understand and use this form of sorting data (from the reference
manual):

*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
* In this example, the base array has the values aa44 bb33 cc22 dd11
* so the overlaid array ARRO has the values 44 33 22 11.
*D DS
D ARR 4 DIM(4) ASCEND
D ARRO 2 OVERLAY(ARR:3)
D*
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
C
* After the SORTA operation, the base array has the values
* dd11 cc22 bb33 aa44
*C
C SORTA ARRO*
===============================================================================

But I am thinking I should be learning about Qualified data structures.
D ArSfl ds qualified
D ArField1 like(Field1) dim(300)
D ArField2 like(Field2) dim(300)
D ArField3 like(Field3) dim(300)
D ArField4 like(Field4) dim(300)
D ArField5 like(Field5) dim(300)
D ArField6 like(Field6) dim(300)
D ArField7 like(Field7) dim(300)

If I do:
sorta ArSfl.ArField4
will the other 6 fields be sorted too, and not corrupt my data?

(Any other comments about this are more than welcome. Something is
making me think I am wandering too far astray.)

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.