[comp.lang.pascal] Left Justifying

specter@disk.UUCP (Byron 'Maxwell' Guernsey) (09/08/89)

Is there any buily in way to left justify fields in the write or writeln 
statements? I have been unable to find one, and just assumed that all fields
were right justified. If your lost consider the following.....
WRITELN('This text.':12);
would yield the output...
  This text.
Suppose I wanted it to justify into the left field.. like so...
WRITELN('This text.':12,'foo');
This text.  foo
Is there a way other than a user procedure to do this?

-- 
Byron 'Maxwell' Guernsey                |       ///  //\\
specter@disk.UUCP     or                |      ///  //  \\
uunet!ukma!corpane!disk!specter         |  \\\///  //====\\
"Sometimes death is better..." - S. King|   \\\/  //      \\ m i g a

mlw@pyr.gatech.EDU (Michael Williams) (09/11/89)

In article <537@disk.UUCP> specter@disk.UUCP (Byron 'Maxwell' Guernsey) writes:
>Suppose I wanted it to justify into the left field.. like so...
>WRITELN('This text.':12,'foo');
>This text.  foo
>Is there a way other than a user procedure to do this?
>

   It's not pretty, but one way to do this using turbo pascal is to use the
built in string functions:

   st := 'This text.';
   writeln(st,' ':12-length(st),'foo');

  Doing this adds enough extra blanks to bring the total length to 12.  What
happens when the string to be written is too long for the field width is your
problem; at least it doesn't crash.
-- 
Michael Williams
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!mlw
ARPA: mlw@pyr.gatech.edu

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/12/89)

In article <537@disk.UUCP> specter@disk.UUCP (Byron 'Maxwell' Guernsey) writes:
>Is there any buily in way to left justify fields in the write or writeln 
>statements? I have been unable to find one, and just assumed that all fields

The function TRIMFLFN in TSUNTD.TPU in /pc/ts/tspas13.arc does that. 
It is available by anonymous ftp from our site.  (A justify function
is not difficult to write for a string.  The trick is to make the
function reasonably fast.)

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

MATHRICH@umcvmb.missouri.edu (Rich Winkel UMC Math Department) (09/12/89)

>From: Byron 'Maxwell' Guernsey <specter@disk.uucp>
>Is there any buily in way to left justify fields in the write or writeln
>statements? I have been unable to find one, and just assumed that all fields
>were right justified. If your lost consider the following.....
>WRITELN('This text.':12);
>would yield the output...
>  This text.
>Suppose I wanted it to justify into the left field.. like so...
>WRITELN('This text.':12,'foo');
>This text.  foo
>Is there a way other than a user procedure to do this?

If you're talking about TP, you could use the LEFT() function in my
STRINGS.TPU:

writeln(left('This text.',12,' ')) prints 'This text.  '
(the third argument is the pad character)
Being written in assembler, it's likely to be as fast as any built-in
function might be.
Send me mail for further info.

MATHRICH@UMCVMB.MISSOURI.EDU
MATHRICH@UMCVMB.BITNET