|
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.
C 1 do 9 x 1 0 C x dsply a 1 C enddo C seton lr
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.