|
boldt@ca.ibm.com wrote:
> Mike wrote:
> >I'm trying to join the twentieth century here and replace all my MOVEs
> >with EVALs, but this one has me stuck. If I have a 9-element array RA and
> >I want to fill the last three elements with, say, "X", I can code:
> >
> >MOVEA *ALL('X') RA(7)
> >
> >Is there a way I can do the same thing using EVAL?
>
> Barbara wrote:
> >Here's another way that will probably perform somewhat better,
> >if the number of elements is very large (which it's not in
> >your case):
> >
> >D data s 65535a based(pData)
> >D pData s *
> >C eval pData = %addr(RA(7))
> >C eval numElems = %elem(RA) - 7 + 1
> >C eval %subst(data : 1 : %size(RA) * numElems)
> >C = *ALL'X'
I don't like MOVEA for clearing specific hardcoded elements of an array,
but, forgive me Barbara, I would much rather use MOVEA than the above
because MOVEA is clearer as to what is happening.
> If you always know that you just want to set the last three
> array elements, I'd probably just code it as:
>
> RA(%elem(RA)-2) = *all'X';
> RA(%elem(RA)-1) = *all'X';
> RA(%elem(RA) ) = *all'X';
>
> Anyways, personally, I don't think this qualifies as a
> "reasonable" use of MOVEA. For most "normal" situations,
> the FOR loop is a good alternative.
FWIW, when I look at old code and see a MOVEA clearing some number of
elements of an array where the element is hardcoded, I immediately feel
I have a design issue.
--
-Jeff
New email address: jlcrosby@dilgardfoods.com
The opinions expressed are my own and not necessarily
the opinion of my company. Unless I say so.
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.