Vern Hamberg wrote:
1. Dimension the data structure - give it a length equal to the sum of
the lengths of those 7 fields.
Right, except you don't need to explicitly specify the length of a
qualified data structure. Better to let the compiler figure out the
length unless you really need the data structure to have a particular
length longer than the natural subfields would give it.
2. Take the dim() off each subfield
Right.
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
Or just code the subfields without the overlay keywords. Using
OVERLAY(DS:*NEXT) wouldn't add anything.
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.
You can't sort the data structure array by specifying one of the
subfields even if the subfields are defined to overlay the DS.
This is illegal if ArSf1 is an array:
SORTA ArSf1.ArField4
But in 7.1, you can code this to sort the ArSf1 data structure array by
the ArField4 subfield, keeping the other subfields in synch the way
Booth wants:
SORTA ArSf1(*).ArField4
Prior to 7.1, you have to jump through a few hoops to sort the DS array
by one of its subfields. Paul's article mentions one way using
pointers, but that way seems quite error prone to me. I'd use qsort
instead no matter how big the array is; qsort is quite straightforward
once you'd done it once.
As an Amazon Associate we earn from qualifying purchases.
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.