Kbase 15781: How to RIGHT JUSTIFY a character field using 4GL
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to RIGHT JUSTIFY a character field using 4GL
There is no function in PROGRESS language that will right justify a
character field, however one can write a 1 line function to do this.
It is done by padding the left side of the character field with the
right number of blanks to push the string to the right.
e.g. To right justify a display field of 20 characters :
DEF VAR blanks AS CHARACTER FORMAT "x(20)". /* = display field */
DEF VAR a AS CHARACTER FORMAT "x(15)".
blanks = FILL(" ",20). /* starting with a string of 20 blanks */
OUTPUT TO file-a.
a = "THIS".
a = SUBSTRING(blanks,1,(20 - LENGTH(a))) + a.
PUT a SKIP.
a = "WILL".
a = SUBSTRING(blanks,1,(20 - LENGTH(a))) + a.
PUT a SKIP.
a = "RIGHT".
a = SUBSTRING(blanks,1,(20 - LENGTH(a))) + a.
PUT a SKIP.
a = "JUSTIFY".
a = SUBSTRING(blanks,1,(20 - LENGTH(a))) + a.
PUT a SKIP.
The output file-a will be :
THIS
WILL
RIGHT
JUSTIFY
Progress Software Technical Support Note # 15781