|
Hi Tony,
> D ExtHist DS Qualified
> D Dim(4)
> D ResultCode 5I 0 Inz(0)
> D AsgDate D Inz(*Loval)
> D ExtDate D Inz(*Loval)
>
> Reset *All ExtHist;
>
> I am getting results as though the reset option is not working. This is the
> first time I have used RESET with an array, as I thought it would make nicer
> code than a for-endfor loop, resetting three fields each time.
I don't think RESET understands arrays of data structures. When you pass
it your array name in the result field, it thinks it's just a normal DS,
and clears just one instance of it.
I think it's completely ignoring the '*ALL' keyword. I could be wrong,
but in my tests, it still only clears the first element.
As an alternative, you might consider having a "virgin" copy of the data
structure, and set all elements to the virgin copy when you want to reset
it.
I don't know if you realize this or not, but you can set all elements of
an array with a single line of code. Instead of saying MyArray(1), you
can say MyArray(*), and it will set all elements.
Here's a sample program that uses this technique:
d TestDS ds qualified
d Field1 7P 2 inz(1.1)
d Field2 10A inz('TEST TEST')
d Field3 1A
d MyArray ds likeds(TestDS)
d dim(10)
d inz(*LIKEDS)
D x s 10I 0
/free
// just for test purposes, put some junk into the
// array.
for x = 1 to %elem(MyArray);
MyArray(x).Field1 = 4444.44;
MyArray(x).Field2 = '5555555555';
MyArray(x).Field3 = 'Z';
endfor;
// This works like a RESET op-code
MyArray(*) = TestDS;
*inlr = *on;
/end-free
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.