Kbase 21197: 4GL. How to Display the Format Correctly with Dynamic Values.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/12/2008 |
|
Status: Verified
GOAL:
How to Display the Format Correctly with Dynamic Values.
FACT(s) (Environment):
Progress 9.x
CAUSE:
If you are trying to display a dynamic value, you could possibly find that the value you are trying to display does not have the expected format.
Example:
DEFINE TEMP-TABLE ttTest
FIELD Nr AS DECIMAL.
DEFINE VARIABLE wbh AS HANDLE NO-UNDO.
DEFINE VARIABLE wfh AS HANDLE NO-UNDO.
ASSIGN wbh = BUFFER ttTest:HANDLE
wfh = wbh:BUFFER-FIELD("Nr").
CREATE ttTest.
ASSIGN ttTest.Nr = 0.4.
DISPLAY ttTest.Nr
wfh:BUFFER-VALUE FORMAT "->>>>9.9999"
wfh:BUFFER-VALUE = 0
DECIMAL(wfh:BUFFER-VALUE) FORMAT "->>>>9.9999"
DECIMAL(wfh:BUFFER-VALUE) = 0.
Will return the result:
0.40 ->>>>..4 yes 0.4000 no
This is not a bug but rather a difference between static values being displayed and dynamic ones. The compiler has no idea what data-type BUFFER-VALUE is, or anything else about it. So it just assumes it is a character expression.
FIX:
If you want to change the format of a dynamic value, you have to use the FORMAT and STRING-VALUE attributes of the BUFFER-FIELD widget, and give the DISPLAY statement a character buffer that is wide enough.
ASSIGN wfh:FORMAT = "->>>>9.9999".
DISPLAY wfh:STRING-VALUE FORMAT "x(20)".
The BUFFER-VALUE is intended for the native datatype, and is displayed in dump format, whereas STRING-VALUE pays attention to what the FORMAT attribute has.