Display Question

nate100

Member
i have a char field with 100 as the format.

If user enters 60 chars only, then i want to display only 60.
say if user enters 70 i want to display only 70.

Thanks in advance
 
Hi ,

I got this from knowledge base

Code:
ID: P117058
Title: "4GL: How to use FORMAT dynamically in 4GL"
Created: 06/28/2006Last Modified: 10/16/2008Status: Unverified


[B]Goals:  [/B]
4GL/ABL:  How to use FORMAT dynamically in 4GL 
How to specify FORMAT in runtime 
Example of FORMAT value being defined from a variable in 4GL


[B]Facts:  [/B]
Progress 9.x 
OpenEdge 10.x 
All Supported Operating Systems


[B]Fixes:  [/B]
Use the following piece of code:

/* Example 1 of dynamically changing the variable FORMAT */
[B]DEFINE VARIABLE cFormatVariable  AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName    AS CHARACTER NO-UNDO.
DEFINE VARIABLE cValueToDisplay  AS CHARACTER   NO-UNDO.[/B]
[B]ASSIGN
    cVariableName = "ABCDEFGHIJKLMNOP"
    cFormatVariable = 'x(10)'
    cValueToDisplay = STRING( cVariableName, cFormatVariable).[/B]
/* Example 2 of dynamically changing the variable FORMAT */
[B]DEFINE VARIABLE cFormatVariable  AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName    AS CHARACTER NO-UNDO.[/B]
[B]DEFINE FRAME FrameName cVariableName.[/B]
[B]ASSIGN
    cVariableName = "ABCDEFGHIJKLMNOP"
    cFormatVariable = 'x(10)'
    cVariableName:FORMAT = cFormatVariable.[/B]
/* Example 3 of dynamically changing the variable FORMAT */
[B]DEFINE VARIABLE cFormatVariable AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVariableName   AS CHARACTER NO-UNDO.[/B]
[B]ASSIGN
    cVariableName = "123456789012345678901234567890".[/B]
[B]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.[/B]
 
While one can do things like gnome has indicated, it would help if you were more clear about what you were actually trying to accomplish in context. If you have an "X(100)" format and only 70 characters in the field, that is all that will be displayed ... so what is it that you are trying to change? Do you have fields to the right which you would like to shrink-to-fit so there is no whitespace? If you were doing that on the screen I would ask how you were going to handle the data entry and suggest that you not do it because moving things around on the screen is confusing to users. If you are outputting this to disk or a printer, then possibly PUT UNFORMATTED would do the trick for you quite simply. But, let us know what you really want to have happen and what you have tried and what was undesireable about it.
 
Back
Top