Consultor Eletrônico



Kbase P117058: 4GL: How to use FORMAT dynamically in 4GL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

4GL/ABL: How to use FORMAT dynamically in 4GL

GOAL:

How to specify FORMAT in runtime

GOAL:

Example of FORMAT value being defined from a variable in 4GL

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
All Supported Operating Systems

FIX:

Use the following piece of code:

/* Example 1 of dynamically changing the variable FORMAT */
DEFINE VARIABLE cFormatVariable AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cValueToDisplay AS CHARACTER NO-UNDO.
ASSIGN
cVariableName = "ABCDEFGHIJKLMNOP"
cFormatVariable = 'x(10)'
cValueToDisplay = STRING( cVariableName, cFormatVariable).
/* Example 2 of dynamically changing the variable FORMAT */
DEFINE VARIABLE cFormatVariable AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName AS CHARACTER NO-UNDO.
DEFINE FRAME FrameName cVariableName.
ASSIGN
cVariableName = "ABCDEFGHIJKLMNOP"
cFormatVariable = 'x(10)'
cVariableName:FORMAT = cFormatVariable.
/* Example 3 of dynamically changing the variable FORMAT */
DEFINE VARIABLE cFormatVariable AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName AS CHARACTER NO-UNDO.
ASSIGN
cVariableName = "123456789012345678901234567890".
OUTPUT TO 'FileName.txt'.
cFormatVariable = 'x(10)'.
PUT "Displaying the variable with the Using 'x(10)' FORMAT" SKIP.
PUT cVariableName FORMAT cFormatVariable SKIP.
PUT "Displaying the variable with the Using 'x(20)' FORMAT" SKIP.
cFormatVariable = 'x(20)'.
PUT cVariableName FORMAT cFormatVariable.
OUTPUT CLOSE.