117 lines
2.4 KiB
Groff
117 lines
2.4 KiB
Groff
.TH padstring "" "" "/rdb Command"
|
|
.PC "Return string with blanks to fill a field"
|
|
\fBpadstring [-]\fIlength string\fR
|
|
.PP
|
|
.II "string^pad with spaces"
|
|
The command
|
|
.B padstring
|
|
adds blanks to the end of
|
|
.I string
|
|
to make it the requested
|
|
.IR length .
|
|
This command useful for screen and report writing,
|
|
where you want to line up everything.
|
|
.PP
|
|
The option
|
|
.I -length
|
|
means to left-justify the string in the field, that is,
|
|
write the padding blanks to the end of
|
|
.IR string .
|
|
The option
|
|
.IR length ,
|
|
without the hyphen,
|
|
right justifies the string \(em that is, it adds the spaces to the
|
|
beginning of
|
|
.IR string .
|
|
.SH Example
|
|
The first example
|
|
.DM
|
|
padstring 10 string
|
|
.DE
|
|
.PP
|
|
displays the string:
|
|
.DM
|
|
string
|
|
.DE
|
|
.PP
|
|
Note that the string is right-justified; that is, the spaces were added to
|
|
the left of
|
|
.BR string .
|
|
.PP
|
|
Now we can use this in a
|
|
.B report
|
|
form file to make fixed-length fields.
|
|
An ordinary form has the files to the right of a field, moving all around.
|
|
For example, the command
|
|
.DM
|
|
report form < mailtable
|
|
.DE
|
|
.PP
|
|
writes the output:
|
|
.DM
|
|
Name : Ronald McDonald Company: McDonald's
|
|
Street: 123 Mac Attack
|
|
City : Menphis State : TENN ZIP: 30000
|
|
Phone : (111) 222-3333
|
|
.sp \n(pDu
|
|
Name : Chiquita Banana Company: United Brands
|
|
Street: Uno Avenito De La Revolution
|
|
City : San Jose State : Costa Rica ZIP: 123456789
|
|
Phone : 1234
|
|
.DE
|
|
.PP
|
|
This result is rather messy.
|
|
However, if we edit the file
|
|
.B form
|
|
to include the
|
|
.B padstring
|
|
command, then we will get a fixed form, as follows:
|
|
.DM
|
|
Name : <!padstring -17 '<Name>'!> Company: <Company>
|
|
Street: <Street>
|
|
City : <!padstring -17 '<City>'!> State : <State> ZIP: <ZIP>
|
|
Phone : <Phone>
|
|
.DE
|
|
.PP
|
|
Now, running
|
|
.B report
|
|
on this file yields:
|
|
.DM
|
|
Name : Ronald McDonald Company: McDonald's
|
|
Street: 123 Mac Attack
|
|
City : Menphis State : TENN ZIP: 30000
|
|
Phone : (111) 222-3333
|
|
.sp \n(pDu
|
|
Name : Chiquita Banana Company: United Brands
|
|
Street: Uno Avenito De La Revolution
|
|
City : San Jose State : Costa Rica ZIP: 123456789
|
|
Phone : 1234
|
|
.DE
|
|
.PP
|
|
Note that
|
|
.B State
|
|
has not been done yet, and therefore
|
|
.B ZIP
|
|
moves back and forth;
|
|
but
|
|
.B Company
|
|
and
|
|
.B State
|
|
stay lined up correctly.
|
|
.PP
|
|
Note that if
|
|
.B padstring
|
|
is too long a name, use the COHERENT link command
|
|
.B ln
|
|
to link it to a shorter name.
|
|
.SH "See Also"
|
|
.B
|
|
report,
|
|
screen
|
|
.R
|
|
.br
|
|
COHERENT Lexicon:
|
|
.B
|
|
ln
|
|
.R
|