home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
wp
/
fold30.zip
/
FOLD.DOC
< prev
next >
Wrap
Text File
|
1993-01-31
|
30KB
|
761 lines
FOLD-and-PRINT
version 3.0
User's Manual
(C) Konrad Budych 1989-93
FOLD-and-PRINT is a utility that allows you to print an ASCII text in
a multi-column format using either single sheets or fanfold paper on
(probably) any printer. This saves paper costs and makes it easier to read
texts. It is useful when you want to print long source code listings,
software documentation, or any long and unformatted ASCII texts.
FOLD-and-PRINT always prints in text mode to avoid slow graphics
printing and may use all features that are specific to your printer as it is
completely configurable. It is possible to print selected pages of the text:
even-, or odd-numbered, starting from, or ending after given page. You may
prepare easily printouts that you may bind in a binder. All features are
described later in this manual.
I have been using and writing this program for more than 2 years. It
was improved, changed, and rewritten many times. As I find it really useful I
think it may be useful to others too. Just give it a try, play with some
configurations, and very soon you will discover its value.
Real life example: suppose you want to print both parts of the user's
guide to Pretty Good Privacy, popular freeware public-key encryption program.
It takes 74 pages if you just send both files to printer. But it takes only
23 pages when you remove page headings and print joined manual parts with
FOLD-and-PRINT in two columns on any ESC/P compatible printer using 80 lines
of 160 characters per page which is still very readable. It is less than one
third of the original amount of paper necessary to make the printout...
WHAT DOES FOLD-and-PRINT EXACTLY DO?
====================================
When you print a text with 'COPY ATEXT.EXT PRN', 'PRINT ATEXT.EXT', or
something similar, you usually get a sheet or two (or hundred) of paper or few
meters (or miles) of fanfold paper that has text printed only near the left
margin, has about 50 to 60 lines on page, and is printed with font which you
can set on the printer's panel.
When you browse through the user's manual of any printer, you should
see, that the printer can print in many modes that are mostly unused by
professional, big applications. These applications usually offer much more
features, but they print mostly in graphic modes, and if you have a slow
printer you sooner or later stop using them for printing ASCII texts (if you
have ever started).
Most dot mattrix printers can emulate ESC/P commands. This commands
allow to select different font pitches and line spacings. It is no magic to
print 80 lines of 160 characters on a page. This is still very readable and
there is about 3 times more text on such a page than when you use default 55
lines of 80 characters. Of course if your printer does not support ESC/P
commands you may still use FOLD-and-PRINT. Only you will probably have to
experiment with different features of your printer.
What FOLD-and-PRINT really does is this: it formats a given ASCII
texts into multi-column format, and sends it to the printer, page by page,
preceded and followed by some control codes. The page length, width, margins,
line spacing, etc. are all up to you. Just give FOLD-and-PRINT control codes
to be sent to printer, tell it how many lines fit on a page, how many
characters fit in a line, and that's all! You may make your printouts even in
9 columns from now!
To find more details on how to configure FOLD-and-PRINT see below. If
your printer supports ESC/P (most printers do), you may test using the example
configurations included in the package.
HOW TO INSTALL FOLD-and-PRINT?
==============================
Follow these simple rules when installing FOLD-and-PRINT:
* All *.P files should be in the same directory in which you keep FOLD.EXE.
* It is nice to be able to run FOLD-and-PRINT from any directory and drive.
* Do not install FOLD-and-PRINT if you do not have DOS version 3.0 or newer.
You may just copy FOLD.EXE and *.P files to some directory listed in
your PATH, or create separate directory (like C:\FOLD) and create a BATch file
in one of directories listed in PATH. The batch may look like this:
@echo off
set fold=-a -w -i
c:\fold\fold.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
set fold=
echo on
The FOLD environmental variable is used to turn on default switches.
You may SET it in the batch, in AUTOEXEC.BAT, or do not set it at all if you
do not need it. See below for switches description.
After you have learned how to use and configure FOLD-and-PRINT, do not
keep *.DOC files on your hard disk --- the manuals are longer than the program
itself! Just hide the original archive file on some forgotten diskette in
case you ever want to read this text again or your hard disk crashes.
USING FOLD-and-PRINT
====================
First you will be presented some examples introducing step by step the
major features of FOLD-and-PRINT. The complete syntax and full switches
description is presented at the end of this section.
All these examples assume that you have FOLD-and-PRINT configured and
ready to use. If your printer supports ESC/P, FOLD-and-PRINT is ready to use
with default parameters: the condensed Elite font of 80 lines of 160
characters per page is used by default. Use another mode by copying any .P
file to DEFAULT.P or (which is better) using 'p' switch. If your printer does
not support ESC/P commands you will have to configure FOLD-and-PRINT first.
See below for details.
QUICK START
-----------
To print this file in two columns run:
FOLD -2 FOLD.DOC
You will be prompted for confirmation before the printing starts, and before
each page. Pressing [ESC] always exits to DOS.
If you want to know how many pages of the text will be produced by
FOLD-and-PRINT run:
FOLD FOLD.DOC
FOLD-and-PRINT will analyze the text first, and display how many pages, and
how many 'cuts' (see below) you will get if you use 1, 2, 3, up to 9 columns
of text. Then you will be prompted to press [1], [2], ... [9] to start or
[ESC] to quit. You may always force the analyzis of a text using 'a' switch:
FOLD -2 -a FOLD.DOC
In this case when prompted you just have to press [ENTER] to use 2 columns.
Of course, thanks to 'a' switch, you may use 3 or 8 columns even if you
specified '2' in command line.
WHEN COLUMN IS TOO NARROW
-------------------------
When column is too narrow a 'cut' occurs. Normally the text which
would not fit in a column will be printed in the same column in the next line.
The number of cuts in texts can be determined in text analysis.
When the text is cut, a word may be broken in any place. When many
words in text are broken, the text becomes illegible. To prevent this, you
may use 'w' switch. This makes FOLD-and-PRINT not break words in the middle,
but move an entire word to the next line in the same column. For example:
FOLD -4 FOLD.DOC
would produce a very hard to read printout, but
FOLD -4 -w FOLD.DOC
would produce a not so hard to read printout. Sometimes when a word is longer
than the width of a column it is not possible to leave it intact. In such
cases FOLD-and-PRINT will behave as if the 'w' switch was off.
You may not want to print the line endings that do not fit in a
column. They may contain less important information (like comments in
assembly language source code). But if they are hundreds of cuts the text
becomes hard to understand if you omit them. To truncate lines that do not
fit in a cloumn use 't' switch, for example, compare the analysis rezults of:
FOLD -t FOLD.DOC
and
FOLD FOLD.DOC
especially in 4 or more column modes.
WHEN A RIBBON IS WEAK
---------------------
If you print a lot of texts, sooner or later a ribbon in your printer
will become weak and printouts gray instead of black. You may of course
replace the ribbon, but if it is weak and you very much want to print
something in black FOLD-and-PRINT can help. Use 'b' switch to print each line
not once but twice, or 'b3' to print each line 3 times up to 'b9' which tells
FOLD-and-PRINT to print each line 9 times. The latter is cruel for the
printer, but if you cannot afford a new ribbon... For example:
FOLD -2 -b3 FOLD.DOC
will print FOLD.DOC in two columns each line three times.
WHEN A TEXT IS LONG
-------------------
When a text you print is very long and you print it on fanfold paper
or you have a sheet feeder, you may do not want to sit and look the at printer
working, and pressing [ENTER] from time to time to confirm printing of
succeeding pages. Or you may want to print first the left pages and then the
right pages on the same sheets to make a book-like printout. FOLD-and-PRINT
can help in each situation:
FOLD -n -2 FOLD.DOC
This will print FOLD.DOC in two columns but you will be able to leave the
printer unattended as no user action will be necessary. You only have to
confirm the start of printing, but you may omit even this nuisance:
FOLD -n -c -2 FOLD.DOC
This will automatically start printing of FOLD.DOC and continue without any
prompts, unless you force the text analyzis with 'a' switch in which case you
will have to specify number of columns to be used.
If you want to print only even- or odd-numbered pages of a text use
'e' and 'o' switches:
FOLD -o -n FOLD.DOC
FOLD -e -n FOLD.DOC
These two commands will cause printing the one half of FOLD.DOC first and then
the other half next. Both halves will be printed in no-wait mode described
above.
To print only specified range of pages you may use 'f', 'l', and 's'
switches. Here are some examples:
FOLD -f3 FOLD.DOC
This will print FOLD.DOC starting with page 3.
FOLD -f3 -l4 FOLD.DOC
This will print FOLD.DOC starting with page 3 and ending after page 4.
FOLD -s4 FOLD.DOC
This will print 4th page of FOLD.DOC. Please note that '-s4' is a shortcut
for '-f4 -l4 -e- -o-' and that 'e' and 'o' switches can be combined with 'f'
and 'l'.
WHEN YOU HAVE A BINDER
----------------------
If you like to keep all sheets of your printout tightly bound
together, you may tell FOLD-and-PRINT to leave margins which will allow
binding sheets:
FOLD -2 -m FOLD.DOC
This will print FOLD.DOC in two columns. Right pages (odd-numbered) will have
a left margin and left pages (even-numbered) will have a right margin so the
printout will be excellent to be put in a binder.
Please note that all columns are more narrow if use use this switch.
This may increase the number of cuts in a text.
The width of the binder margin can be set up in the printer definition
file (see below).
COMPLETE SYNTAX AND SWITCHES DESCRIPTION
----------------------------------------
You may run 'FOLD -?' to see the help screen.
The full syntax is as follows:
FOLD [switches] filename [switches]
Switches may be preceded by either '-' or '/'. Switches without
parameters toggle their state each time they occur unless they are followed by
'+' or '-'. Switches must be separated. The content of environmental
variable FOLD is always scanned before any command line arguments, so you may
turn on some switches using this variable.
Filename is any legal DOS filename with optional drive and path.
Wildcards ('*' and '?') are not allowed and only one file name can be given.
Single '-' or '/' in command line disables switch scanning. This
feature may be used to print a file with the name beginning with '-'.
Some switches automatically turn on or off other switches. See
detailed switches description below for more details.
Here is the full list of switches that are available in FOLD-and-PRINT
version 3.0:
-1, -2, -3,... -9 : number of columns
-a : force text analyzis
-t : truncate lines that don't fit in a column
-w : use word wrap when breaking long lines
-e : print even-numbered pages only (2, 4, 6, ...)
-o : print odd-numbered pages only (1, 3, 5, ...)
-m : make binder margins
-i : print 'This space intentionally left blank' on last page
-zfilespec : set output file to <filespec>
-pfilespec : use printer def file <filespec>
-fnnn : first page to print is nnn (default: 1)
-lnnn : last page to print is nnn (default: 9999)
-snnn : select page to print
-b[n] : print each line n times
-n : no pause after page for paper change
-c : start printing without waiting for confirmation
-h, -? : display help screen
And here is the detailed description of all switches:
-1, -2, -3,... -9
These switches can be used to specify the desired number of columns
which FOLD-and-PRINT should use when printing text. If none of them is
specified, FOLD-and-PRINT will analyze the text first and then prompt user to
specify the number of columns. However if 'a' switch is on, FOLD-and-PRINT
will always analyze the text.
If any two of these switches are given the last is valid. Everything
after the digit is ignored (including '+' and '-').
-a
This switch forces the text analyzis. FOLD-and-PRINT read the text
first and display how many pages, and how many cuts you will get if you use 1,
2, 3, up to 9 columns of text. Then you will be prompted to press [1], [2],
... [9] to start or [ESC] to quit.
The analyzis is very fast: on 386 40 MHz it was around 3500 lines of
the text per second.
Please note, that you will always be prompted to press a key, even if
you turn on 'c' and 'n' switches.
-t
This switch will tell FOLD-and-PRINT to truncate lines that don't fit
in a column. The text that is truncated will not be printed anywhere on the
page. Normally too long lines are printed in 2 or more lines in a column.
-w
This switch will tell FOLD-and-PRINT to use word wrap when breaking
too long lines that do not fit in a column. When 't' switch is on, however,
'w' is ignored.
-e
With this switch on, FOLD-and-PRINT will print only even-numbered
pages of the specified range. To be precise: it will not print odd-numbered
pages.
-o
With this switch on, FOLD-and-PRINT will print only odd-numbered pages
of the specified range. To be precise: it will not print even-numbered pages.
-m
This switch tells FOLD-and-PRINT to make margins which will make easy
to put a printout into a binder. The width of the margin is defined in the
printer definition file (see below).
-i
There is no much use of this switch --- it makes FOLD-and-PRINT print
on the last page, which is usually not filled up, the following text in the
middle of the blank space:
[This space has been intentionally left blank]
-zfilespec
When this parameter is given in command line FOLD-and-PRINT will not
send the text being printed to a printer (ie. file PRN) but to the file
specified after 'z'. filespec is any valid file name. If the specified file
exist it will be overwritten without a warning.
Please note that there is no space between 'z' and 'filespec'. If
this parameter is used twice or more, the filespec in the last occurance is
used by FOLD-and-PRINT.
-pfilespec
Normally FOLD-and-PRINT uses prinetr control codes, page layout, and
other configurable information from the printer definition file DEFAULT.P. If
you want to use another printer definition file use 'p' switch followed by
file specification. The default extension which you can omit is '.P'. The
file is first searched for in the current directory and then in the directory
in which FOLD.EXE resides.
Please note that there is no space between 'p' and 'filespec'. If
this parameter is used twice or more, the filespec in the last occurance is
used by FOLD-and-PRINT.
-fnnn
nnn is a number form 1 to 9999. All pages before the nnn'th page will
not be printed. The first printed page will be nnn'th or the one after nnn'th
if 'e' and 'o' switches does not allow printing of the nnn'th page.
Please note that there is no space between 'f' and the following
number. If this parameter is used twice or more, the number in the last
occurance is used by FOLD-and-PRINT.
-lnnn
nnn is a number form 1 to 9999. All pages after the nnn'th page will
not be printed. The last printed page will be nnn'th or the one before nnn'th
if 'e' and 'o' switches does not allow printing of the nnn'th page.
Again please note that there is no space between 'l' and the following
number. If this parameter is used twice or more, the number in the last
occurance is used by FOLD-and-PRINT.
-snnn
nnn is a number form 1 to 9999. Only the nnn'th page will be printed.
The '-snnn' is a shortcut for '-fnnn -lnnn -e- -o-'.
Once again please note that there is no space between 's' and the
following number. If this parameter is used twice or more, ... etc...etc...
-b[n]
n is a digit 1, 2, up to 9. It can be omitted and in this case 2 is
assumed. The '-b-' is the same as '-b1'. FOLD-and-PRINT will boldface a
printout --- each line of text will be printed n times without a linefeed.
Do please note that there is no space between 'b'...etc... And if
this parameter is used twice...etc..etc..
-n
Normally FOLD-and-PRINT before it starts printing a given page it
stops --- allowing you to change the paper --- and displays a question like
this:
Page 4: reading.... print (Y/n/a)?
You may press [Y] (or [ENTER]) to print this page, [N] not to print, or [A] to
print this and all following pages without the prompts. [ESC] aborts program.
If 'n' switch is used FOLD-and-PRINT does not ask these questions.
-c
Normally FOLD-and-PRINT before it starts printing at all displays a
question like this:
Confirm: start printing (Y/n)?
You may press [Y] (or [ENTER]) to print this page, [N] (or [ESC]) not to print
and return to DOS. If 'n' switch is used FOLD-and-PRINT does not ask this
question.
-h, -?
Use this to display the help screen. FOLD-and-PRINT will not do
anything else if this switch is given. It cannot be turned on and off.
HINTS
-----
Here are some hints which you may find helpful in using
FOLD-and-PRINT. Please also have a look at hints after the 'Configuring...'
section.
* FOLD-and-PRINT can print in one column too. If you want to print a
text in one column with the designed-by-you headers and footers, and have a
all features of FOLD-and-PRINT, just tell FOLD-and-PRINT to use 1 column. For
example:
FOLD -1 SOMETEXT.ASC
* The text analysis is very helpful; you may want to use 'a' switch in
the FOLD variable. Before you print anything you may look at what number of
columns will be the best for a text --- minimum cuts and pages.
* If in the analysis you see that the last page is filled in less than
10 percent you may want to remove some blank lines from the text to make it
fit on fewer pages. Especially if the text contains a groups of more than one
empty line.
* All tabs in the text being printed are expanded to spaces in the
usual manner. All trailing spaces are removed from the input text to avoid
breaking blank lines.
LASER PRINTERS
--------------
I never have an opportunity to print something with FOLD-and-PRINT on
a laser printer. I have no idea what will happen if you try. Maybe it will
work, maybe it will not. It surely will not do any harm to the printer, so
you may try...
COFIGURING FOLD-and-PRINT
=========================
FOLD-and-PRINT uses printer definition files to make the full use of
specific capabilities of your printer. The printer definition file is an
ASCII file that contains all data needed by FOLD-and-PRINT to print a text in
the specific mode.
A single printer definition file contains information about page size
and layout (length of the page in lines, width of the line in characters, the
number of lines at the top and bottom of the page used for margins, the
position within these margins of a header and a footer, and in the end a text
of the header and the footer) and information needed to correctly print in
this mode (printer control codes used to initialize and terminate printing
mode and codes to be printed before and after each page).
SAMPLE PRINTER DEFINITION FILE ------------------------------
The structure of a printer definition file is very simple and very
rigorous. It will be described in detail with the use of an example. Here it
is one of the example printer definition files (the left margin of two tabs
and line number are NOT included in the real file --- DEFAULT.P --- and are
only used to explain the contents of the file in this documentation and for
further explanation):
1 *** Fold 3.0 printer definition file ***
2 any ESC/P compatible printer
3 condensed Elite
4 85 160 2 3 1 3 10
5 This is '%*' printed %B %d, %Y.
6 Page %# of '%*'.
7 \1B@\0F\1B8\1BM\1B0\1BR\00\1Bt\01\1B6
8 \1B@\07
9
10 \0C
11 *** End of printer definition file ***
The first and the last line (beginning with '***') are necessary for
FOLD-and-PRINT and always have the same contents. Everything after 11th line
is ignored.
The 2nd and 3rd line contain the text describing your printer (line 2)
and the print mode which is used (line 3). They are only displayed on the
screen and have no meaning to 'the real work'.
The 4th line contains 7 numbers and they are respectively:
* the length of the page in lines (85 in the example)
* the width of the line in characters (160 in the example)
* the number of empty lines at the top of page used as margin (2)
* the number of empty lines at the bottom of page used as margin (3)
* the position of the line with header within the top margin (1)
* the position of the line with footer within the bottom margin (3)
* the width of binder margin (10 characters)
If the last two numbers are out of range defined by 3rd and 4th
number, the header and/or footer will not be printed.
The 5th line contains the header text and the 6th one --- the footer.
This can be any text of your choice and you may use some special symbols there
(they all begin with '%', a time is the time of printing):
%F or %* name of printed file
%N or %# current page number
%a or %A weekday name (abbr or full)
%b or %B month name (abbr or full)
%c Date and time (DON'T USE! See notes below)
%d 2 digit day of month (01..31)
%H or %I 2 digit hour (00..23 or 01..12)
%j 3 digit day of year
%m 2 digit month decimal (01..12)
%M 2 digit minute (00..59)
%p AM or PM
%S 2 digit second (00..59)
%U or %W 2 digit week number (Sun is 1st or Mon is 1st day of week)
%w Weekday decimal (0 = Sunday)
%y or %Y Year (00..99 or 4 digit)
%x Date
%X Time
%Z Time zone name (DON'T USE! See notes below)
%% %
You should not use %c which gives date and time because it also appends
new-line characters and this may spoil your calculations (two lines printed
instead of one). Also %Z should not be used unless you have environmental
variable TZ set properly --- this variable describes the time difference
between your time zone and Greenwich Mean Time. I will not describe its
format here and you are unlikely to use time zone name as a part of the header
in your printouts. But if you really want --- please see the description of
'strftime' and 'tzset' C library functions for details in any serious C
compiler manuals.
Lines 7 thru 10 contain printer control codes which are used:
* to initialize the printer and turn on the desired print mode (line 7)
* to return the printer to default mode after printing is complete (line 8)
* to initialize printing of each page (line 9)
* to end printing of each page (line 10)
Non-visible control codes or non-ASCII charcters can be entered as
hexadecimal codes in the format '\nn' (without quotes) where nn are exactly
two hex digits (0..9, A..F). For example \1B is ESC (ASCII 27) character.
In the example shown above we initialize the printer with ESC @
(standard initialize for ESC/P printers) \0F (= SI condensed printing) ESC 8
(ignore out of paper --- alows printing more on the page) ESC M (Elite pitch)
ESC R 0 ESC t 1 ESC 6 (use IBM character set I, allow printing upper codes,
and use US characters --- this is not important, but allows printing texts
with characters > 128). We de-initialize printer with ESC @ BELL (some
printers rings when they receive bell character and this let you know that
printing is finished). After each page we send FF (form feed) to spit out the
page.
HOW DOES FOLD-and-PRINT USE THE PRINTER DEFINITION FILE?
--------------------------------------------------------
Here is the detailed step-by-step description of what use
FOLD-and-PRINT makes of each item in the printer definition file:
Lines beginning with '***' are ignored, but necessary; lines 2 and 3
are displayed on-screen and also ignored. Numbers in the 3rd line (PL - page
length, LW - line width, MT - top margin, MB - bottom margin, LH - line with
header, LF - line with footer, BM - binder margin; BM is internally reset to
zero if 'm' switch is off) are used to calculate column width (which is equal
to: (LW - BM) / #_of_columns - 1) and some other numbers...
FOLD-and-PRINT starts with sending control codes from line 7 to the
printer. Then for the each page it repeats:
* sending control codes from line 9
* printing PL lines of which:
** first MT lines are blank except for LH'th line which contains header as
found in line 5 with expanded symbols beginning with '%'
** next PL - (MT + MB) contain a text formatted in a number of columns of
your choice (2 to 9)
** last MB lines are blank except for LF'th line which contains footer as
found in line 6 with expanded symbols beginning with '%'
* printing control codes from line 10
The printing is terminated with sending control characters from line 8.
Each line of text contains a pair of CR and LF characters at the end
so you must turn off auto line feed feature of your printer if it on. Surely
it is off --- most programs require that it is off.
It is all that you need to set up your printer. Please remember that
FOLD-and-PRINT absolutely relies on you and assumes that you configured it
correctly. If the printer prints strange things --- it is most likely your
fault! Please read 'Hints...' below for the last help on configuring.
HINTS AND TROUBLESHOOTING
-------------------------
Here are some notes which you may find helpful in configuring
FOLD-and-PRINT and if you have troubles with FOLD-and-PRINT:
* If every other line printed is full and every another is not, and
page does not fit on a single sheet, you decrease the value of line width
(line is simply too long) or change some codes to decrease character pitch.
* If line spacing is too large, turn off the auto line feed feature in
your printer or put in printer definition file some codes which decrease line
spacing.
* If a page does not fit on a single sheet of paper (eg. the footer
is printed on the next sheet) reduce the page length value or make printer
ignore the end of paper (the latter is often better --- it is possible to
print the footer at the very end of the sheet).
* When you use fanfold paper always turn off the skip over perforation
and adjust top and bottom margins.
* If you use fanfold paper and the second (and next) page(s) do(es)
not start at the same position as first, calculate page length, divide by line
spacing and put apropriate values in the printer definition file, or...
* If you use fanfold paper and the second (and next) page(s) do(es)
not start at the same position as first, calculate page length, put codes to
set this value in line 7 (printer initialization) and add FF (form feed) to
line 10.
* If you use a laser printer you may be in trouble --- I have had no
opportunity to find out what FOLD-and-PRINT does with laser printers...
FINAL NOTES
===========
Some legal issues and other information are not included in this part
of the manual --- they are not necessary here and may annoy someone who wants
to get some help out of this text and does not want to browse through revision
history, acknowledgements, etc. Also such information may annoy much more if
you have a habit of printing software documentation.
So please have a look at FOLDADD.DOC sometime...
End of User's Manual
********************