Kbase 6196: Sample routines to right-justify character field
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Sample routines to right-justify character field
DOS (MS-DOS) hi-d,,,901030-51041,pjhDEF VAR x AS CHAR FORMAT "X(30)".
DEF VAR y AS INT.
DEF VAR q AS INT.
DEF VAR z AS CHAR.
FOR EACH customer:
z = "". /* this resets z for each iteration*/
DISPLAY name.
y = 30 - LENGTH(name). /* find out how many to pad */
DO q = 1 TO y: /* loop through y times */
z = z + " ". /* concatenate spaces tog. for pad */
END.
x = z + name. /* new field - Pads + orig */
DISPLAY x.
END.
Another more direct method to do this:
DEF VAR x AS CHAR FORMAT "X(30)".
FOR EACH customer:
x = FILL(" ",(30 - LENGTH(name)) + name.
DISPLAY name x.
END.
Progress Software Technical Support Note # 6196