11. Report-Writer Expressions and Formats : Format Specifications : Character String Format C : C Format Examples
 
Share this page                  
C Format Examples
These examples illustrate the use of the C format.
Example 1:
Suppose your report contains a character column called name that you want to print, and a value for name is Jones, J. Then, suppose you issue the following six .print statements:
.print 'First :', name (c15),':First' .nl
.print 'Second:', name (c4), ':Second' .nl
.print 'Third :', name (c0), ':Third' .nl
.print 'Fourth:', name (-c15), ':Fourth' .nl
.print 'Fifth :', name (+c15), ':Fifth' .nl
.print 'Sixth :', name (*c15), ':Sixth' .nl
The print statements produce, respectively, the following six lines of output:
First :Jones, J.      :First
Second:Jone:Second
Third :Jones, J.:Third
Fourth:Jones, J.      :Fourth
Fifth :      Jones, J.:Fifth
Sixth :   Jones, J.   :Sixth
Example 2:
If your data includes the character string, "Now is the time for all good men to come to the aid of their party.", the following table shows the effect of three different format specifications used to print the output on multiple lines in three different ways:
c0.15                cf100.15            cj0.15
Now is the time      Now is the time     Now is the time
 for all good m      for all good        for   all   good
en to come to t      men to come to      men to  come to
he aid of their      the aid of          the    aid   of
 party.              their party.        their party.
Because the second format specification, cf100.15, specifies an actual number of character positions to print, Report-Writer prints out two blank lines after the text, to pad out the 75 characters already printed to the full 100-character column width specified.
After Report-Writer prints a string in column format, it sets the position for the next text output to the top line of the column, at the end of that line (in the example, this would be after "time").