Easily Avoid a Common Data Structure Error
February 25, 2009 Ted Holt
|
A shop with which I’m acquainted had an undesirable experience recently. A program that, to my understanding, had been working properly, ended abnormally. The error could have easily been avoided, had the programmer followed one simple rule of thumb. Take a look at the following program fragment.
D MyData ds
D OneField 4a
D TwoField 7p 0
D RedField 3s 0
D BlueField 5u 0
D
D Number s 15p 5
/free
Number = TwoField;
If the calculation is the first executable statement in the program, what is the new value of Number? The answer is that Number never gets |


