Was this helpful?
Character String Format C
Use the C format to print string expressions.
The syntax of the C format specification is:
[-|*|+] c[f|j][s]n[.w]
where:
f
Instructs Report-Writer to fold (wrap) text by breaking between words when printing strings that span multiple lines. Tab and carriage return characters produce tab and carriage return actions within the string. Must be specified in conjunction with either w and/or n.
j
Instructs Report-Writer to fold (wrap) text by breaking between words, and to right justify text by padding the line with blanks between words, when printing strings that span multiple lines. Tab and carriage return characters produce tab and carriage return actions within the string. Must be specified in conjunction with either w and/or n.
s
Instructs Report-Writer to strip trailing spaces.
n
Specifies the maximum number of characters to print. If there are more than n characters in the string, it truncates the excess. If there are fewer, it pads the rest of the string with blanks until n characters have been printed. Use a value of 0 for n if the entire string is to be printed, regardless of its length.
w
Specifies the number of characters to print on each line. If n is greater than w, then more than one line is written, in newspaper-style column format. By default, w is set to n.
When specifying the previous options, you can use either uppercase or lowercase letters interchangeably. The optional field width n can be specified to give an exact width. If n is specified and the character string is less than n characters wide, blanks are added to the output to assure n characters. If the string is longer than n characters, only the leftmost n characters are printed and the rest are ignored.
If you specify a value for w as well as n, you can print text in column format (that is, newspaper style). The f and j modifiers can be used to assure breaking of words at blanks, or right justification of text. If neither is specified, simple wrap-around of text occurs, regardless of where the line break might occur.
Report-Writer has a default maximum of 310 lines for printing a character string. If you exceed this maximum, some of the text can not appear in your report. You can override the default by specifying the -wmxwrap parameter on the command line.
If you use the C format statement, the following unprintable characters are printed as spaces:
Horizontal tab
Vertical tab
Line feed
Form feed
Carriage return
Note that tabs and carriage returns cause tabs and carriage return actions if you are using multi-line formats, such as cf or cj.
To print a visual representation of unprintable characters, use the T format statement (see page 47).
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”).
Last modified date: 04/03/2024