User Guide
Chapters
Table of Contents
Financial Utility

Document Formatting Utility

Copyright (C) 1990 - 2000 Terry D. Boldt, All Rights Reserved


Dot Commands
Formatter Variables
Formatter Variable Default Values
Formatter Functions

The document formatting utility formats documents using 'dot commands'. All commands start with a period as the first character of a line followed by two or more characters of the command. Each command performs a specific formatting task. All of the commands are listed below. Formatter internal variables or user defined variables may be imbedded in the text as "{variable_name}" and are replaced before dot commands are recognized.

The formatter is used to format documents as:

qtawk -f fmtdoc.exp document-source-1 document-source-2

The formatted documents are output to the standard output file and may be redirected or piped as desired or applicable. For example, under Linux, the 'lpr' utility is usually used to send output to a printer:

qtawk -f fmtdoc.exp document-source-1 | lpr


Commands

The available commands are:
.* .ad .bm
.br
.cc
.ce
.ds
.elif
.else
.endif
.fo
.fr
.fs
.hr
.hs
.h[0-9]
.if
.il
.im
.in
.ll
.pa
.pl
.pn
.pp
.pt
.px
.se
.sp
.sr
.ss
.sx
.tb
.tc
.td
.tl
.tm
.us





:li.
:ol.
:sl.
:ul.
:e[osu]l.


Blank input line Breaks paragraph formation, Causes current line to be output and signals start of new paragraph.
.* comment line. Any line beginning with this sequence will be ignored
.ad
.sr
.ad == Addressee's address.
.sr == sender's address

Tag each line as:

.sr Jane Doe
.sr 1243 Tech Way
.sr Thistown, PA 22111

Line is added to sender's address array. Will be printed in upper left corner of envelope if envelope printed. Line reformatted as:

".tb xx addr"

where 'xx' is replaced by the current value of the 'sender_tabs' variable.

.ad John Doe
.ad 1324 Monarch Lane
.ad Anytown, VA 11222

Line is added to adressee's address array. Will be printed in center of envelope if the envelope is printed. Each Line reformatted as:

".br addr"

.cc Output Control Codes to the printer. The control cdes are specified on the same line. The form is:

.cc [i] "control string";

For example the control string to turn on compressed printing on most Epson printers is hexadecimal 0xf. This would sent to the printer as:

.cc i "\x00f";

The optional 'i' commands the format utility to send the control string to the printer immediately. If the 'i' is not specified, the control string is prepended to the next word formatted and sent to the printer when the line containing the word is output.

.fo turn formatting on or off or specify ragged right or left margin. There are four forms of this command:
  1. .fo on - turn formatting on. All text will be justified to both the left and right margins. Blanks will be inserted as necessary to accomplish this. If the total length of the words on the line plus a single blank between words plus the value of the 'adjust' formatter variable is less than the current line length, then the line is not justified on the right and only a single blank is inserted between each word.
  2. .fo off - turn formatting off. All lines are output exactly as input.
  3. .fo right - text is formatted with a single blank between each word only and justified to the right margin, i.e., the left margin is "ragged".
  4. .fo left - text is formatted with a single blank between each word only and justified to the left margin, i.e., the right margin is "ragged".
  5. .fo center - text is formatted with a single blank between each word and centered on the line. Both right and left margins are "ragged".
.br break command. Output current line and format any text on line
.ce Text center line. Center the text speified on the line. For example:

.ce This line centered

                       This line centered                        
.il xx indent line. Break and indent next output line xx spaces. If xx is not an integer, the current indentation is used.
.im imbed file specified. May only imbed to a depth of one level. Processing continues on current file at current location at end of imbedded file. Files in the same directory as the current input file may be imbedded with the simple command:

.im {FILEPATH}filename

If the files to be imbedded are all in the same directory, which is different from the directory of the current imput file, then the following sequence of commands will find and imbed them:

.se dir = "Desired_directory_path";
.im {dir}filename
.in [-+]xx indent. Indent remaining lines at xx spaces. If xx is not an integer, the default left margin indentation is used, 0. If xx is prefixed by '+' or '-', the current indentaion is incremented/decremented the specified amount.
.ll line length. Set line length to xx characters. If xx is not an integer, the default line length is used, 75.
.h[0-9] Section header command. The form of the command is (for a 1st level header):

.h1 Title Text

The Section header title text is formatted with the number of the section header. The section headers are numbered consecutively starting with 1. All lower level sections numbers are reset to 1. Thus, the sequence of commands:

.h0 Top level section
.h1 First Level Subsection
.h2 Second Level Subsection
.h3 Third level Subsection
.h3 Third level Subsection
.h3 Third level Subsection
.h2 Second Level Subsection - second header
.h3 Third level Subsection
.h3 Third level Subsection
.h1 First level Subsection
.h2 Second level Subsection
.h3 Third level Subsection

.h0 Top level section - Second Chapter
.h1 First Level Subsection
.h2 Second Level Subsection
.h3 Third level Subsection
.h3 Third level Subsection
.h3 Third level Subsection
.h2 Second Level Subsection - second header
.h3 Third level Subsection
.h1 First level Subsection
.h2 Second level Subsection
.h3 Third level Subsection

Is formatted as:

1.0 Top level section
1.1 First Level Subsection
1.1.1 Second Level Subsection
1.1.1.1 Third level Subsection
1.1.1.2 Third level Subsection
1.1.1.3 Third level Subsection
1.1.2 Second Level Subsection - second header
1.1.2.1 Third level Subsection
1.1.2.2 Third level Subsection
1.2 First level Subsection
1.2.1 Second level Subsection
1.2.1.1 Third level Subsection

2.0 Top level section - Second Chapter
2.1 First Level Subsection
2.1.1 Second Level Subsection
2.1.1.1 Third level Subsection
2.1.1.2 Third level Subsection
2.1.1.3 Third level Subsection
2.1.2 Second Level Subsection - second header
2.1.2.1 Third level Subsection
2.2 First level Subsection
2.2.1 Second level Subsection
2.2.1.1 Third level Subsection

If '0' is specified, a page eject is performed if the output is not currently at the top of a page. Also, another page eject is performed if the current page is then even. Also, if the internal variable 'reset_headr_0' is true, page numbering is reset to 1 for a '.h0' command. The valu eof the 'reset_headr_0' variable may be set with the '.se' command. It has a default value of zero, 0.

The formatter variable 'header_0_text' is set equal to the text of "Title Text". This can then be used for headers and footers as well as including into other text, e.g.,

.fr even |Document Title|- # -|{header_0_text}|
.fr odd |{header_0_text}|- # -|Document Title|

All Section header commands insert the header title text into the Table of Contents.

.hr page header. Set page header line. Forms are:
  1. .hr on - turn on page header printing.
  2. .hr off - turn off page header printing.
  3. .hr even text - set page header text for even pages.
  4. .hr odd text - set page header text for odd pages.
  5. .hr text - set page header text for all pages, even and odd.

The default header line for even pages is:

"||- # -||"

and for odd pages is:

"||- # -||"

Note that the header text acts the same as the '.sx' command text.

Note: the page header command does not take effect until the current page has been printed and before the next page is started. If the output is currently at the top of a page, e.g., immediately following a ".pa" command, then the page header command takes effect immediately.

.hs header skip. Set page header skip. Forms are:
  1. .hs - set header skip to default value of 1 line
  2. .hs n - set header skip to n lines
  3. .hs +n - increment header skip by n lines
  4. .hs -n - decrement header skip by n lines

The header skip lines are output as blank lines after writing the page header.

.fr page footer. Set page Footer line. Forms are:
  1. .fr on - turn on page footer printing
  2. .fr off - turn off page footer printing
  3. .fr even text - set page footer text for even pages
  4. .fr odd text - set page footer text for odd pages
  5. .fr text - set page footer text for all pages

The default footer line for even pages is:

"||- # -||"

and for odd pages is:

"||- # -||"

Note that the footer text acts the same as the '.sx' command text.

Note: the page header command does not take effect until the current page has been printed and before the next page is started. If the output is currently at the top of a page, e.g., immediately following a ".pa" command, then the page header command takes effect immediately.

.fs footer skip. Set page Footer skip. Forms are:
  1. .fs - set footer skip to default value of 1 line
  2. .fs n - set footer skip to n lines
  3. .fs +n - increment footer skip by n lines
  4. .fs -n - decrement footer skip by n lines

The footer skip lines are output as blank lines before writing the page footer.

.if
.else
.elif
.endif
The formatter supports conditional formatting of source text. The 'if' conditional, 'elif' conditional, 'else' alternative conditional and 'endif' commands are supported.
  1. .if - 'if' conditional.

    The form of this command is

    .if vaue expression

    If the value expression evaluates to a TRUE, i.e., non-zero numeric or non-empty string, then the source lines following the '.if' command are formatted. Formatting continues until a '.elif' or '.else' command line is encountered. If either of these commands is encountered, then formatting stops until an '.endif' command line is encountered.

    If the value expression evaluates to a FALSE, i.e., zero numeric or empty string, then the lines following the '.if' command are skipped until an '.elif', '.else' or '.endif' command line is found.

  2. .elif - 'else if' conditional. The form of this command is

    .elif vaue expression

    If a previous '.if' command line was encountered which evaluated to a FALSE value, then this line is executed and the value expression is evaluated. This command is then the same as an '.if' command line. If the previous '.if' command line evaluated to TRUE, then formatting stops until an '.endif' command line is encountered.

  3. .else - 'else'.

    If a previous '.if' command line was encountered which evaluated to a FALSE value, then formatting commences with the source text following this command line until and '.endif' command line is encountered. Formatting then continues as normal following the '.endif' command line.

  4. .endif - end conditional clause

    This line serves to terminate the '.if', '.elif' and '.else' formatting commands. Formatting continues normally with text line following this command line.

Note that it is possible to nest '.if' conditional commands within other '.if', '.elif' and '.else' conditional command line text.

As an example of the '.if' conditional command, consider the situation where you want a certain amount of text to be printed on the same page, say 5 lines. If fewer than 5 lines are left on the current page, then a page eject should be executed, otherwise a simple blank line is desired. The following sequence of commands will accomplish this task:
.if ( (line_cnt + 5) > num_lines )
.pa
.else
.sp
.endif

.pl xx page length. Set page length to xx lines. If xx not specified or not an integer, set to default value equal to the value of the formatter variable {d_page_length}, 66. The value of 'd_page_length' may be changed with the '.se' command.
.tm xx Top Margin. Set top margin to xx lines. If xx not specified or not an integer, set to default value, 0. The top margin lines are blank lines output after the physical top of page and before the page header text is output.

Note: the Top Margin command does not take effect until the current page has been printed and before the next page is started. If the output is currently at the top of a page, e.g., immediately following a ".pa" command, then the page header command takes effect immediately.

.bm xx Bottom Margin. Set bottom margin to xx lines. If xx not specified or not an integer, set to default value, 0. The bottom margin lines are blank lines output after the page footer text is output and before the physical end of page.

Note: the Bottom Margin command does not take effect until the current page has been printed and before the next page is started. If the output is currently at the top of a page, e.g., immediately following a ".pa" command, then the page header command takes effect immediately.

.pa xx Page Eject. If xx specified, eject xx pages. If xx is not an integer, eject to the top of the next page only.
.pn Page Number. Forms are:
  1. .pn xx - set current page number to xx
  2. .pn +xx - increment page number by xx
  3. .pn -xx - decrement page number by xx
  4. .pn alpha ([-+]xx) - change page numbering to alphabetic numerals. If [-+]xx is specified, then decrement or increment by xx or set page number to xx.
  5. .pn roman ([-+]xx) - change page numbering to roman numerals. If [-+]xx is specified, then decrement or increment by xx or set page number to xx.
  6. .pn arabic ([-+]xx) - change page numbering to arabic numbers, same as 'normal'. If [-+]xx is specified, then decrement or increment by xx or set page number to xx.
  7. .pn normal ([-+]xx) - change page numbering to arabic numbers. If [-+]xx is specified, then decrement or increment by xx or set page number to xx.
  8. .pn - set current page number to 1
.pp Print Page Command. Forms Are:
  1. .pp [T] p1 [p2] - print pages from p1 up to and including p2. If p2 not specified print to end of document.
  2. .pp [T] even - print only even numbered pages
  3. .pp [T] odd - print only odd numbered pages

if 'T' or t' is specified, then use total page count, i.e., page count starting with first page and incrementing by one for each page. Otherwise use page number as optionally adjusted by '.pn' command

.ds Double Space. Set line spacing to double space
.se Set variable. Forms are:
  1. se on - turn on variable replacement in text. On by default.
  2. se off - turn off variable replacement in text
  3. se var_name = value expression

    if "var_name" is either 'Document_date_Format' or 'Document_time_Format', the date or time format for document is been changed and the current document date/time is updated to the new format. Note that "value expression" may contain any QTAwk variable, formatter variable or even define new variables. In addition, the expression may use any QTAwk built-in function or formatter function. A list of formatter functions which may be useful is included below. As an example, the following '.se' command defines and sets a new variable and utilises the formatter 'roman_num' function.

    .se yr = roman_numeral(1999);

    sets yr to: "mcmxcix"

.ss single space. Set line spacing to single space
.sp xx space. Skip xx lines. If xx not specified or not an integer, 1 used
.sx split text. Form of command:

.sx |Left field|center|Right field|

Left field                   center                   Right field

The blank space following the 'x' of the command is required. "Left Field" is positioned on the left margin, "Center" is positioned centered on the line and "Right Field" is positioned on the right margin. The first character after the blank character following 'x' is used as the field separater. The above .'sx' command could also be written as:

.sx ~Left field~center~Right field~

or

.sx xLeft fieldxcenterxRight fieldx

The use of non-alphabetic characters makes the field separators stand out more.

The value of the internal variable 'stx_chr' is used as the fill character between the three fields. The value of 'stx_chr' is a blank character by default, but may be changed to any other desired value. For example:

.se stx_chr = '=';
.sx ~Left field~center~Right field~
.se stx_chr=' ';

Left field===================center===================Right field
.tb xx text tab "text' is positioned at the xx character position of the current line. If xx is not an integer, 0 is used.
Lists Three kinds of lists are formatted:
  1. :ol. - Ordered list. Each item of the list is started by a numeric. List item numbering alternates between arabic numerals and alphabetic numerals. Thus, a second level embedded list would be numbered as 'a.'. Odd level list items use arabic numbers, even level list items use alphabetic numbers. The character terminating the item number varies with the nesting level. The following characters are used at the nesting level specified:
        1.  1
    a) 2
    1> 3
    a} 4
    1] 5
    a: 6
    1| 7
    a* 8
    1_ 9
    a^ 10

    The variable "order_list_num" is set to the number of the current ordered list item.

  2. :ul. - Unordered list. Each item of the list is started by a printable graphic character. The following graphic characters are used for successive levels of nested unordered lists:
    1. blst_odd == 'þ'
    2. blst_even == '-'
        þ  unordered list item - 1st level
    - unordered list item - 2cd level
    þþ unordered list item - 3rd level
    -- unordered list item - 4th level

    The printable character starting each list item may be changed with the '.se' command. For example:

    .se blst_oh = blst_odd;
    .se blst_eh = blst_even;
    .se blst_odd = '~';
    .se blst_even = '=';
    :ul.
    :li.unordered list item - 1st level
    :ul.
    :li.unordered list item - 2cd level
    :ul.
    :li.unordered list item - 3rd level
    :ul.
    :li.unordered list item - 4th level
    :eul.
    :eul.
    :eul.
    :eul.
    .se blst_odd = blst_oh;
    .se blst_even = blst_eh;

    Will produce the results:

        ~  unordered list item - 1st level
    = unordered list item - 2cd level
    ~~ unordered list item - 3rd level
    == unordered list item - 4th level
  3. :sl. - Simple List. Each item of the list is simply started by the text of the item. No special character shows the start of the item:
        Simple list Item #1
    Simple List item #2

    Simple lists are good for short items all on one line.

        This is the first item of a simple list.  This item by
    intention is longer than one line and will be formatted
    across two line or more lines.
    This is the second item of a simple list.
    Third item.

Each item of any of the above list types is started with the command, ':li.'. For example the simple list above is:

:sl. 
:li.Simple list Item #1
:li.Simple List item #2
:esl.

A list is halted with the commands:

  1. :eol. - for ordered lists
  2. :eul. - for unordered lists
  3. :esl. - for simple lists

Note: if blank lines are desired between list items, the blank lines must be present in the source document. The formatter does not auotmatically insert blank lines between list items.

List items are formatted with second and higher lines of any list item indented four spaces in from the beginning character of the item. The indentation for succeeding lines of any list item is in the variable 'list_indent'. The value of this variable may be changed with the '.se' command:

.se list_indent = 6;

to change the indentation of all lines after the first for list items.

There are several formatter variables used for formatting lists.

  1. olist - this variable is used for ordered lists only and is equal to the nesting level for ordered lists. A zero, 0, value, indicates no active ordered list.
  2. ulist - this variable is used for unordered lists only and is equal to the nesting level for unordered lists. A zero, 0, value, indicates no active unordered list.
  3. lstb - this is a singly dimensioned array with indices running from 0 to 9. Each element contains the character used to terminate the numeric used for an ordered list at that list nesting level for ordered lists. The values are:

    lstb[0] == ^
    lstb[1] == .
    lstb[2] == )
    lstb[3] == >
    lstb[4] == }
    lstb[5] == ]
    lstb[6] == :
    lstb[7] == |
    lstb[8] == *
    lstb[9] == _

    The character used for any particular ordered list level may be set using the '.se' command.

  4. list_level - this variable holds the depth of list nesting. It is equal to zero, 0, if no list is currently active and incremented by one, 1, for each list activated.
  5. list_list - this is a singly dimentsioned array, indexed by list level. If
    1. list_list[list_level] == 0 --> the current list is an unordered list
    2. list_list[list_level] > 0 --> the current list is a ordered list. The sequence number of the current list item is equal to list_list[list_level]. The sequence numbering of the current ordered list item may be retained for future use quite simply as the following commands:

      .se current_item_number = ((olist & 1) ? list_list[list_level] : d_to_alpha(list_list[list_level])) >< lstb[olist % 10];

    3. list_list[list_level] < 0 --> the current list is a simple list

NOTE: the variables:

  1. olist
  2. ulist
  3. list_level
  4. list_list
Should NEVER be altered within the document using the ".se" command.

The fourth type of list is the Definition list, started with the ":dl." command. Starting a definition list with the ":dl." command outputs all text read thus far. Each item of the definition list consists of two parts:

  1. definiton term introduced with the command ":dt.". The text following the definition term command is formatted and output with no indentation. All previous text is output first.
  2. Term definition introduced with the command ":dd.". All text from the ":dt." command is output and the left margin is indented to offset the definition.

The definition list is terminated with the ":edl." command.

An example of a definition list is:
:dl.
:dt.Leopard
:dd.a large, strong cat of southern Asia and Africa that is usually tawny or buff with black spots arranged in broken rings or rosettes.
:dt.leotard
:dd.a close fitting one-piece garment worn by dancers, acrobats, and aerialists.
:edl.

Which would be formatted as:

Leopard
a large, strong cat of southern Asia and Africa that is usually
tawny or buff with black spots arranged in broken rings or
rosettes.
leotard
a close fitting one-piece garment worn by dancers, acrobats, and
aerialists.
.tc xx Table of Contents. This command reserves xx pages for the table of contents.
.pt text put table of contents command. This command puts 'text' into the Table of contents with the current page number. The current page number style used, arabic, alphabetic or roman.
.px Define Extra Page Number. Forms are:
  1. .px n xx - set extra page number n to xx
  2. .px n +xx - increment extra page number n by xx
  3. .px n -xx - decrement extra page number n by xx
  4. .px n alpha ([-+]xx) - change extra page number n numbering to alphabetic numerals. If [-+]xx is specified, then decrement or increment by xx or set extra page number n to xx.
  5. .px n roman ([-+]xx) - change extra page number n numbering to roman numerals. If [-+]xx is specified, then decrement or increment by xx or set extra page number n to xx.
  6. .px n arabic ([-+]xx) - change extra page number n numbering to arabic numbers, same as 'normal'. If [-+]xx is specified, then decrement or increment by xx or set extra page number n to xx.
  7. .px n normal ([-+]xx) - change extra page number n numbering to arabic numbers. If [-+]xx is specified, then decrement or increment by xx or set extra page number n to xx.
  8. .px n - set extra page number n to 1

This command mimics the '.pn' command. The formatting utility updates the extra page numbers at the same time that the normal page number is updated. This allows the user to define, set and track page numbers for special sections within a document. n in the command can be any integer. The page numbers can be accessed and printed in headers and footers using the replacement symbols:

&n

where n is the extra page number

The extra page number value may also be accessed within the document through the formatter variable:

page_xtra[n][0]

The formatting style (roman, alphabetic or arabic) may be accessed through the formatter variable:

page_xtra[n][1]

Where a value of:
0 == arabic format
1 == alphabetic format
2 == roman numeral format

Tables Tables are supported and formatted using two commands
  1. .td - Table definition. This command defines the table structure and the character used to start table columns. The form of the command is:

    .td ~ n1 n2 n3 n4 n5 n6 n7 ...

    The first non-blank character is the table column start character. It is used in the text to denote where the text for a table column starts for that table row. Each line of source text starts a new table row. No blank lines are inserted. Blank lines in the source will insert a blank line in the output. 'n1', 'n2', etc. define the start character position in the output for the corresponding table column. Note that the text for a given column may overflow into following columns. If the following columns are filled, the text for the following column(s) will overlay the overflowed text.

  2. .tl (start|stop) - table start/stop command. Once a table structure has been defined with the '.td' command, this command will start table formatting and then stop table formatting.

A table is defined as follows:

.td ~ 1 10 20 30 40 50

The table is then started with the '.tl start' command. The following example demonstrates formatting a table. Note that empty table columns must be indicated with the column character followed by blank space. This allows for some columns to have text which overflows into following columns.

.td ~ 1 10 20 30 40 50
.tl start
~col 1 ~col 2 ~col 3 ~col 4 ~col 5~col 6
~column 1 with overflowing text~~col 3~col 4 ~col 5~col 6
~col 1~~~col 4~col 5
.tl stop

This table formats as:

col 1    col 2     col 3     col 4     col 5     col 6           
column 1 with overfcol 3g texcol 4 col 5 col 6
col 1 col 4 col 5
.us underscore. Underscore text. This command has four forms:
  1. us on - start underscoring from the current word until the next command is input
  2. us off - stop underscoring started by the previous command
  3. us text - underscore the first word following the command. If 'text' has more than one word, only the first is underscored. All remaining words are ignored
  4. us - underscore the remainder of the current output line only

Formatter Variables

The following internal variables are maintained for formatting. The values of these variables are available using the variable replacement mechanism, namely enclosing the desired variable name within curly braces, "{}", within the text to be formatted. The '.se on' and '.se off' commands turn this replacement mechanism on/off as desired. Thus, {line_cnt} will be expanded into the current line number on the current page as: "1"


adjust
alpha_num
blst_even
blst_odd
bot_margin
break_on_blank_line
date
Document_date_Format
Document_time_Format
double_blank
double_space
footer
ftr_lines
ftr_line_even
ftr_line_odd
ftr_skip
hdr_lines
hdr_line_even
hdr_line_odd
hdr_skip
header
header_0_text
hn_emphasize
left_m
left_margin
line_cnt
list_indent
num_lines
page_length
page_num
page_num_prefix
page_num_sym
paginate
paper_output
reset_headr_0
roman_num
sender_tabs
stx_chr
sysdayofm
sysdayofw
sysdayofy
sysmonth
sysyear
time
toc_ftr_line_even
toc_ftr_line_odd
toc_hdr_line_even
toc_hdr_line_odd
top_margin
ttl_page_cnt
var_replace
width




adjust specifies maximum number of padding characters to be used in justifying a line between the left and right margins. For example, if a line is composed of 10 words with a total length of 55 characters, there would be a minimum of 9 padding caracters between the 10 words for a total length of 64 characters. If the line length is 70 characters, then an additional 6 padding characters must be added between the words to justify them on the line. If 'adjust' is 5, then the words will not be justified. However, if 'adjust' is 6 or more, then the words will be justified and the additional padding characters added between the words. The default value of 'adjust' is 5. This variable may be set using the '.se' command.
break_on_blank_line Specifies whether or not a blank input line will cause formatting of input to break, i.e., to stop adding words to current output line and output current output line. If variable TRUE, default value, a blank input line will cause formatting to break. A value of FALSE will cause a blank input line to be ignored.
line_cnt current line number being formatted. Do not change the value of this variable.
page_length page length of the printed page. This is the number of printed lines on the physical page. For example, 11 inch long paper, printed 6 line per inch yields a value of 66 for page_length. The value may be changed using the '.pl' command. Defaults to the value of 'd_page_length', which may be set via the '.se' command.
paper_output TRUE/FALSE. TRUE if paper is output, FALSE otherwise. If not set on the QTAwk command line via the QTAwk '-v' option:

qtawk -v "paper_output=FALSE'

the formatter sets the value to TRUE at initialization. The value may be set at any time in the source text using the command:

'.se paper_output=FALSE;"

paginate TRUE/FALSE. This variable determines whether or not output is split into pages on output. On initialization, it is set to TRUE if paper_output has a true value, FALSE otherwise. The value may be changed with the '.se' command. During initialization, The default values of the top margin, 'd_top_margin', the bottom margin, 'd_bot_margin', page width, 'd_width', and left margin, 'd_left_m', are set according to the value of 'paginate':
paginate   d_top_margin    d_bot_margin   d_width   d_left_m
TRUE 6 6 65 8
FALSE 0 0 75 0
top_margin the number of blank lines alloted between the top of the physical page and the first header line or text line if no header is printed. Defaults to 'd_top_margin'. The value of 'd_top_margin' may be set with the '.se' command.
bot_margin the number of blank lines alloted between the last line of the footer if printed or the last text line and the bottom of the physical page. Defaults to 'd_bot_margin'. The value of 'd_bot_margin' may be set with the '.se' command.
left_m the number of character spaces used in the left margin. Default to the value of 'd_left_m', which may be set via the '.se' command.
width the number of character spaces on the physical page. Defaults to 'd_width', which may be set via the '.se' command.
header boolean value. If true, then a page header is printed. Set via the '.hr on/off' command.
footer boolean value. If true, then a page footer is printed. Set via the '.fr on/off' command.
sender_tabs the number of space characters used to align the senders address fields. May be set via the '.se' command.
page_num_sym the character replaced by the current page number in header and footer lines. May be set via the '.se' command.
hdr_line_even the text used for the header line on even numbered pages. The text acts the same as the text for the '.sx' command. Set via the '.hr even text' or '.hr text' commands. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
hdr_line_odd the text used for the header line on odd numbered pages. The text acts the same as the text for the '.sx' command. Set via the '.hr odd text' or '.hr text' commands. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
ftr_line_even the text used for the footer line on even numbered pages. The text acts the same as the text for the '.sx' command. Set via the '.fr even text' or '.fr text' commands. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
ftr_line_odd the text used for the footer line on odd numbered pages. The text acts the same as the text for the '.sx' command. Set via the '.fr odd text' or '.fr text' commands. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
toc_hdr_line_even the text used for the header line on even numbered Table of Contents pages. The text acts the same as the text for the '.sx' command. Set via the '.se ' command only. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
toc_hdr_line_odd the text used for the header line on odd numbered Table of Contents pages. The text acts the same as the text for the '.sx' command. Set via the '.se ' command only. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
toc_ftr_line_even the text used for the footer line on even numbered Table of Contents pages. The text acts the same as the text for the '.sx' command. Set via the '.se ' command only. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
toc_ftr_line_odd the text used for the footer line on odd numbered Table of Contents pages. The text acts the same as the text for the '.sx' command. Set via the '.se ' command only. Defaults to the value of 'dhdr_line', which may be set via the '.se' command.
header_0_text The text on the line with the last '.h0' command
hdr_lines the number of lines in the header if printed. Defaults to 1. May be set via the '.se' command.
hdr_skip the number of blank lines between the last line of the printed header and the first line of formatted text. May be set via the '.se' command.
ftr_lines the number of lines in the footer if printed. Defaults to 1. May be set via the '.se' command.
ftr_skip the number of blank lines between the last line of formatted text and the first line of the footer if printed. Defaults to 1. May be set via the '.se' command.
num_lines the number of lines of formatted text on the printed page. The value is computed as:
num_lines = page_length - top_margin - bot_margin
- (header * (hdr_lines + hdr_skip))
- (footer * (ftr_lines + ftr_skip));

If any one of the variables used in computing 'num_lines' is changed, then 'num_lines' is updated. Care should be excercised in changing 'hdr_lines' or 'hdr_skip' in the middle of a page. If the header has already been printed, changing the value of 'hdr_lines' or 'hdr_skip' will dynamically change the number of formatted text lines which may then exceed the physical page. This should probably be fixed at some time.

ttl_page_cnt total page count. This number starts at 1 and is incremented for each page output. This number differs from the variable 'page_num' in that page numbering cannot change this variable. This variable should never be changed by the user with the '.se' command.
page_num the page number of the current page being formatted. This number is the number actually used in replacing the value of 'page_num_sym' in header and footer lines. The value of this variable can be changed with the '.h0', '.pn' and '.tc' commands.
page_num_prefix the text string prefixed to the current page number. After formatting the current value of 'page_num', the string value of this variable is prepended and the resulting string is used to replace the 'page_num_sym' in headers, footers and the Table of Contents pages.
left_margin the number of scpace characters used for the left margin.
double_space True/False value which determines if double line spacing is used for the formatted output.
roman_num true if roman numerals used for page numbers. Set via the .'pn' command.

Examples:

1999 =  mcmxcix
2000 = mm
5 = v
alpha_num true if alphabetic numbers used for page numbering. Set via the .'pn' command.

Examples:

1999 =  bxw
2000 = bxx
5 = e
var_replace true if variable replacement is done in input text. Set using the '.se on' or '.se off' commands.
sysyear set to the current year at initialization. numeric value.
sysmonth set to the current month of the year at initialization. Numeric value from 1 to 12.
sysdayofm set to the current day of the month at initialization. Numeric value between 1 and 31.
sysdayofw set to the current day of the week at initialization. Numeric value between 0 and 6 inclusive.
  1. 0 == Sunday,
  2. 1 == Monday,
  3. 2 == Tuesday,
  4. 3 == Wednesday,
  5. 4 == Thursday,
  6. 5 == Friday, and
  7. 6 == Saturday.
sysdayofy set to the current day of the year at initialization. Numeric value between 0 and 365.

January 1 == 0.

Document_date_Format format string used to format the document date. The value of this variable may be set with the '.se' command.
Document_time_Format format string used to format the document time. The value of this variable may be set with the '.se' command.
date current date on which the document is being formatted. 'Document_date_Format' string used to format the date.
time current time at which the document is started formatting. 'Document_time_Format' string used to format the time.
double_blank True/False value. If true, then two space characters are formatted following words which end with a period, '.'. The value of this variable may be set with the '.se' command.
blst_odd the graphic symbol used as a bullet to odd levels of unordered list items. The value of this variable may be set with the '.se' command.
blst_even the graphic symbol used as a bullet to even levels of unordered list items. The value of this variable may be set with the '.se' command.
list_indent the number of space characters by which lines of list items are indented after the first line of any item. The value of this variable may be set with the '.se' command.
reset_headr_0 True/False value. If true, then 'page_num' is reset to 1 when a '.h0' command is formatted. The value of this variable may be set with the '.se' command.
hn_emphasize true/false value. If true, text formatted with any section header command, '.h[0-9]' is output as emphasized. The value of this variable may be set with the '.se' command.
stx_chr the character value of this variable is used as the padding character for the '.sx' command and the 'split_text' function described below. Initially set to the blank character. The value of this variable may be set with the '.se' command.
order_list_num
The number of the current ordered list item

Formatter Variable Default Values

adjust 5
alpha_num 0
blst_even
-
blst_odd >
bot_margin 6
dftr_line ||- # -||
dhdr_line ||- # -||
Document_date_Format %A, %B %d, %Y
Document_time_Format %I:%M %p
double_space 0
d_bot_margin 6
d_left_m 8
d_page_length 66
d_top_margin 6
d_width 65
footer 1
ftr_lines 1
ftr_line_even ||- # -||
ftr_line_odd ||- # -||
ftr_skip 2
hdr_lines 1
hdr_line_even ||- # -||
hdr_line_odd ||- # -||
hdr_skip 2
header 0
hn_emphasize 1
left_m 8
left_margin ""
list_indent 4
num_lines 63
order_list_num 0
page_length 66
page_num 0
page_num_prefix ""
page_num_sym #
paginate 1
paper_output 1
reset_headr_0 0
roman_num 0
sender_tabs 35
stx_chr " "
toc_ftr_line_even ||- # -||
toc_ftr_line_odd ||- # -||
toc_hdr_line_even |||Table of Contents|
toc_hdr_line_odd |Table of Contents|||
top_margin 6
var_replace 1
width 65

Formatter Functions

The following functions have been defined in the formatter utility and may be used in '.se' commands in the document to be formatted.
roman_numeral(num) function returns integer value of 'num' as a roman numeral string. For example, the '.se' command

.se yr = roman_numeral(1999);

will yield the string "mcmxcix" for the value of 'yr'.

d_to_alpha(num)

function returns integer value of 'num' as an alphabetic string. For example, the '.se' command

.se yr = d_to_alpha(1999);

will yield the string "bxw" for the value of 'yr'.

split_text(text,line_width,fill_chr)

returns a string formed from the string value of 'text'. 'text' is composed of three parts, the first character of 'text' is used as the separator character for the three parts. The first part is justified to the leftmost position on a line 'line_width' characters wide. The second part is centered on the line and the third part is aligned to the rightmost position of the line. The character positions between the three parts are filled with the first character of the 'fill_chr' parameter. This function is used to format the text of the '.sx' command and all page headers and footers with 'fill_chr' equal to the 'stx_chr' formatter variable. The commands:
.se splt = split_text("|Left|center|right|",50,'~');
.se ruler = copies(srange('0','9'),5);

Will yield the following value for the variables 'splt' and 'ruler':


Left~~~~~~~~~~~~~~~~~~center~~~~~~~~~~~~~~~~~right

01234567890123456789012345678901234567890123456789
set_pnum(pnum)

returns a string with the current page number formatted according to the setting of 'roman_num' and 'alpha_num'. The value of the 'page_num_prefix' variable has been prepended to the formatted number in the returned string.

name_defined(name)

returns a TRUE or FALSE value depending on whether a formatter internal variable has been defined with a name equal to the string value of 'name'.

addcomma(x,nfmt)

returns a string with the numeric value of x formatted using the QTAwk 'sprintf' internal function using the string value of 'nfmt' as the formatting string. If 'nfmt' has a false value, i.e., is the null string or a zero numeric value, then the formatting string "%.16g" is used. The integer portion of the numeric value is then broken into units of three digits separated by the grouping symbol, e.g., ','. For example, the following commands will produce the strings shown:

.se val1 = addcomma(12345678.8765,"");
yields val1 == "12,345,678.8765"

.se val2 = addcomma(12345678.8765,"%i");
yields val2 == "12,345,678"

fmt_eng(n,r)

returns a numeric formatted in engineering notation, 'r' specifies the maximum digits following the decimal point. 'n' is formatted as:

abs(n) > 1 ==> [DD]D.DDDeN where first two digits are not both zero
abs(n) < 1 ==> 0.[00]DDDDeN

and N is a multiple of 3.

For example, the following commands will produce the string shown:

.se val3 = fmt_eng(12345678.8765,9);
yields val3 == "12.345678876e6"

.se val4 = fmt_eng(12345678.8765,5);
yields val4 == "12.34568e6"


TOP
User Guide
Chapters
Table of Contents
Financial Utility