|
> But to the question at hand, which is, does "DO *HIVAL" loop an > indeterminate number of times? Well, technically, yes. At least, if you > compile using TRUNCNBR(*YES), which is the default. By default, decimal > arithmetic on fixed-form calcs (but not the expression calcs) truncates > on overflow. That means that when the implicit loop index reaches the > value of *HIVAL, rather than overflowing when it's incremented again, it > gets truncated. Thus, the implicit loop index never exceeds the limit, > and the loop keeps churning away. (At least until the operator notices > and cancels the job!) Wow... that's obscure. I can't believe people would write code like this! I mean, if we didn't have the ability to get answers from the compiler team, how would I have EVER known that "DO *HIVAL" was going to loop infinitely? It sure isn't obvious. > But in my opinion, "DO *HIVAL" is bad style. Other techniques, like the > "DOU FOREVER;" mentioned by someone else, are preferable. Amen! "DO *HIVAL" is very bad style. It's comparable to multiplying a numeric date field by 100.0001. I like "dow 1=1" because it's obvious. Anyone who reads that code knows that 1 will always be the same as 1, so the loop will go on forever. I also like "dow forever" or "dou forever" it may not be as obvious how the code works as "dow 1=1" but it's self-documenting and efficient...
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.