Thanks Hans. As I thought more about it, I did not use pointers at all. In
my original note, I stated I could create a "sort" column, which would
receive a copy of the data I want sorted and output - and this is exactly
what I did. Along with judicious use of %subarr, I was able to greatly
reduce the codebase and have only one array for operations.
With a sortvalue field, I performed the equivalent of:
sortvalue = topqty; // copy item quantity array to sortvalue.
sorta sortvalue;
ShowTopN(start:end:10); // show top 10 by quantity
sortvalue = topcost; // extended cost
sorta sortvalue;
ShowTopN(start:end:10); // show top 10 by extended cost
...
And this is exactly what I hoped to accomplish. The ShowTopN procedure, and
a graphing routine that runs behind it, only reference the sortvalue()
array.
One question though: can I do a LIKEDS on this structure?
d ds
d toplist 90 dim(1000) descend
d topdept inz like(sqlrow.department)
d overlay(toplist:1)
d topitem inz like(sqlrow.item)
d overlay(toplist:*next)
...
Since the DS does not have a name, how does one reference it for
duplication? I recall giving a name to the DS but it generated a compiler
system error. I apologize but I did not retain the relevant error.
The program is working very well for me. Thanks everyone for feedback and
bouncing ideas!
--Loyd
On Fri, May 1, 2009 at 4:07 PM, Hans Boldt <hans@xxxxxxxxxx> wrote:
Loyd: Why complicate matters by using pointers?
There are two issues:
First, you have two structures with identical layout. You define the
structure layout ONCE. Then, you define two DS arrays using LIKEDS.
Second, you want to have identical code to process the two arrays. That
means you want ONE procedure, where the DS array is passed as a parameter.
Cheers! Hans
As an Amazon Associate we earn from qualifying purchases.