|
Constants are always better than hard-coding the value, so that's a great job in and of itself. Using %ELEM() in your code is more clear, only because cCMLimit is an ambiguous name, as re fields with special symbols in them, such as CM# and IN#.
It was the unambiguity of %Elem(ArrayName) that suddenly popped into my head today for who knows what reason. One of those Aha! things that you wonder why you never thought of it years ago.
Certainly %elem(CM#) is clear that you're using the number of declared elements for the array CM#, but what does that array contain?
CM# is Credit Memo Number. Even though I converted everything to RPGIV with a conversion tool eons ago, some field and array names are still remnants of fixed-form RPGIII coding where stuff like "CM#,10" had to fit in 6 columns. I do not miss those days. <g> I can't hardly stand looking at fixed-format RPGIV any more, let alone RPGIII.
Another approach (not a better one, but one of equal honor) is to use %ELEM() everywhere instead of a const. For example: D cCMLimit C Const(20) D CM# S 7 0 Dim(cCMLimit) D IN# S 7 0 Dim(%elem(cm#)) D AMT S 7 2 Dim(%elem(cm#))
That's the one I like.
Then in your code also use %elem(cm#). The benefit of this method, is that it directly says: "Arrays IN# and AMT have the same number of elements as CM# and this was done on purpose and is a requirement."
And that's why it's the one I like. Thanks to all for everyone's 2 cents worth.
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.