by Scott Lippincott » Fri Oct 15, 2010 11:28 am
In Dick's code sample there is no difference in the contents of WS-SERIAL and WS-SERIAL-NO after the assignment. The difference in the way they are displayed is due to the application of a default edit mask.
DEFINE WS-SERIAL W 5 N VALUE 234
DEFINE WS-SERIAL-NO W 5 A
WS-SERIAL-NO = WS-SERIAL
DISPLAY 'WS-SERIAL-NO AFTER NOVE ' WS-SERIAL-NO
In fact, the two fields could redefine the same storage; making the assignment unnecessary.
DEFINE WS-SERIAL W 5 N VALUE 234
DEFINE WS-SERIAL-NO WS-SERIAL 5 A
DISPLAY 'WS-SERIAL = ' WS-SERIAL
DISPLAY 'WS-SERIAL-NO = ' WS-SERIAL-NO
Results in the following:
WS-SERIAL = 234
WS-SERIAL-NO = 00234
The difference is that the default edit mask is applied to the numeric definition. (WS-SERIAL)
DEFINE WS-SERIAL W 5 N VALUE 234 MASK('99999')
DISPLAY 'WS-SERIAL = ' WS-SERIAL
Results in the following:
WS-SERIAL = 00234
Some useful Easytrieve notes:
Numeric data (N or P) defined without a number of decimal places coded is always stored as a positive integer using a sign nibble of x'F'
DEFINE WS-NUM W 6 N VALUE 100 contains hex 'F0F0F0F1F0F0'
DEFINE WS-NUM W 4 P VALUE 100 contains hex '0000100F'
Numeric data (N or P) defined with a number of decimal places coded is stored as above, but the field is signed. Positive numbers are stored as above, and negative numbers are stored with a sign nibble of x'D'.
DEFINE WS-NUM W 6 N 0 VALUE -100 contains hex 'F0F0F0F1F0D0'
DEFINE WS-NUM W 4 P 0 VALUE -100 contains hex '0000100D'
Just one thing that the manual doesn't tell you. Numeric data specified without indicating the number of decimal places is treated as character data in reports. (it does not get accumulated into control total lines) If you want integer totals in report control totals, you must code the number of decimal positions as 0 (zero)