uniform - universal form filer (part 2 of 2)

Istvan Mohos istvan at hhb.UUCP
Thu Mar 1 03:05:25 AEST 1990



.TH UNIFORM 1 ""
.UC 4
.SH NAME
.nh
uniform - universal form filer
.SH SYNOPSIS
.nf
.B uniform
.B uniform \ file
.B uniform \ '&file'
.fi
.SH OVERVIEW
\fBuniform\fR is a program for storing ``box contents'' and for
automatically reprinting such contents
into the appropriate ``boxes'' on pre-printed forms.
.LP
\fBuniform\fR performs two distinct
printer-related tasks.  The first task is reading the input typed on
the computer keyboard, and translating the input to unbuffered
printer output.
The printer serving the \fBuniform\fR process is assumed
not to be a resource
shared among multiple users (at least for the life of the process),
and is
assumed to be in the user's physical vicinity
for sustained visual feedback.
In essence, the printer is made to behave like a typewriter.
.LP
The second task is to record not only the character data that the user
directs to the printer/typewriter, but also the recording
of printer control events that caused
head seeks to the left margin, and of paper feed.
The two tasks combined allow filling boxes on standard
pre-printed forms or questionnaires
from the computer keyboard; and having saved in a file
both text input and the topology of the boxes, allow
future reprinting of the form with a minimum of effort.
.LP
Three distinct variants of the command line syntax accomplish
different goals.  The command given without a file name instructs
\fBuniform\fR that a new form is to be \fIlearned\fR.  A name
of a file in which to store the extracted data,
is interactively requested.  Following this, the user is shown how
to align the blank form in the printer; the user then ``fills out''
the form from the computer keyboard.  The computer screen provides
important visual feedback, prompting when necessary; making the
mechanics of the operation intuitively obvious.
.LP
Having \fIlearned\fR a form in this manner, a
new \fBuniform\fR command of the second form can name
the saved \fIfile\fR on the command line.
This command instructs \fBuniform\fR to fill out a blank form.
The user is shown how to align the blank form as before.
Following this the \fIfile\fR is read, and printer control
codes saved in \fIfile\fR are
expanded to the actual sequences used by the slave
printer.  The user is prompted for supplying new values of
previously named variables.  The form is printed.
.LP
The third variant of the command line
is for continuing an originally interrupted
learning session.  The user aligns the blank form
as before.  Incomplete data already saved in \fIfile\fR is
reprinted into the form.  A new \fIlearn\fR
process is started at this point, aiming to complete the yet
unfilled parts.  Data recorded during the
session is seamlessly appended to \fIfile\fR.

.SH CONTROL CHARACTER SET
Data input to \fBuniform\fR from the keyboard falls into two main
categories: text strings and control bytes.  Text strings are
arbitrary aggregates of all ``printing characters'' (characters
that mark the paper when printed), and the SPACE character
(input by pressing the space bar).  Pressing the TAB key
contributes eight consecutive spaces to the text.  The completion
of a text string is signaled by pressing the RETURN key; the
value of RETURN does not become part of the text string.
.LP
Control bytes to \fBuniform\fR
are ASCII values in the range of 1 through 31.
Control bytes are input to the program by simultaneously pressing
the CONTROL key and an alphabetic character.
Some of the control values
are ``hard wired'' or automatically mapped to keys with familiar
names: CONTROL-H is equivalent to BACKSPACE,
CONTROL-I is equivalent to the TAB key, RETURN is mapped either to
CONTROL-J or CONTROL-M.  ASCII 27 is the ``escape key'' ESC.
Additionally, the SPACE (ASCII 32) character can assume a second role
and become a control byte depending on the operating context.
.LP
\fBuniform\fR uses the BACKSPACE key to negate the rightward
advance (measured in units of ``character pitch'')
of the printer head, or to
move back in a text string to erase errors.  The
DELETE (or DEL) key is remapped to work exactly as BACKSPACE.
Each ``hit'' of the keyboard TAB key or CONTROL-I is identically
converted to eight SPACE characters, and the program immediately
``forgets'' that the eight spaces on record originated as
a single TAB control byte.
.LP
The ESC key propels the program along the chief operating states:
pressing ESC within the form-aligning mode exits that mode and
begins either the form-learning or the form-printing process.
Pressing ESC within the form-learning process signals the completion
of user input, and terminates the program.
.LP
Other control inputs are mapped as easily remembered mnemonics.
Some of these control characters are restricted in scope,
operational only during certain phases of the \fBuniform\fR process.
.LP
.nf
\fB ^A: \fR	ABORT the process, reset printer and terminal.
\fB ^B: \fR	Command printer to print text in BOLD font.
\fB ^C: \fR	Command printer to use COMPRESSED font or character pitch.
\fB ^E: \fR	Command printer to use ELITE font or character pitch.
\fB ^F: \fR	Issue 1/6 inch line FEED (during variable restore only).
\fB ^K: \fR	Command printer to deactivate bold font: KILLBOLD.
\fB ^L: \fR	Issue 1/48 inch LITTL'LINE feed.
\fB ^P: \fR	Command printer to use PICA font or character pitch.
\fB ^R: \fR	REDRAW terminal screen distorted by another process.
\fB ^U: \fR	UNDO entire current line (when creating new form only).
\fB ^V: \fR	Define next text string as VARIABLE.
.fi

.SH "DETAILED DESCRIPTION OF `ALIGN' AND `LEARN'"
At the beginning,
the screen is overlaid with instructions for paper
alignment, and the process is poised for keyboard input.
The first line of the CRT shows the name of the printer
the program expects to control.  It should be a cause for
concern if the printer readied next to the computer is
of a different type from the one assumed by the program.
.LP
The next three lines of the screen contain printer-specific
initialization steps: how to turn on the printer, how to
set up manual margins, how to bring the printer ``on-line''.
The more intelligent the printer, the less text appears in these
lines; in extreme cases the three lines may be blank.
.LP
The next fourteen lines contain a description of the alignment
process, and depict with character-graphics a
conveniently remembered spot on the blank form that should be
aimed for and hit by a character typed at the computer.
The alignment procedure consists of repeated attempts
to print a ``right square bracket'' character \fB\]\fR
at this conveniently remembered spot
just outside the main borders of the form.
(By this time the user should thread a blank
form under the printer head and get it ready for printing.)
.LP
In between tries, the vertical position of the
form should be adjusted manually, or advanced in 1/48 inch
increments by typing CONTROL-L characters from the keyboard.
The horizontal position of the
printer head can be advanced by typing spaces on the keyboard.
The program down-loads the bracket to the printer every time a
RETURN is typed on the keyboard, then immediately returns the
printer head to the leftmost print position, ready for a retry.
The width of the final
``spaces . . . bracket'' string
is the width of an automatic margin for the duration of the
rest of the session.
.LP
Because the designer's and the user's idea of a
``conveniently remembered spot'' may differ, when \fIlearning\fR a
form the user may substitute these fourteen screen lines with
arbitrary text that will hopefully pinpoint a better target for
future recall.  The insertion of the new text is akin to a comment
facility, and begins when a ``black'' or ``printing'' character
is typed during the alignment procedure, instead of the
SPACE/RETURN/CONTROL-L aggregates that direct printer head and paper
movement.  The new text is echoed in the next available one of the
fourteen lines not yet containing user comment, and ends at the
right margin of the screen or by a RETURN from the keyboard.  If the
next key then is a SPACE, RETURN, or CONTROL-L, the adjustment procedure
continues where it was left off.  If the next key is a printing
character instead, a new line of comment is accrued.
The comment text is saved at the beginning of the \fIfile\fR
record of the session, and will automatically appear on the screen
(instead of the original fourteen lines) when adjusting the form
for a reprint.  If the adjustment session is in preparation to
a \fIreprint\fR, the
user's original comments (or lack of) displayed on the screen
(as saved in preparation to a \fIlearn\fR session) can no longer be
changed.
.LP
The alignment procedure ends when the user judges the
most recently printed bracket sufficiently near the
target point.
The final RETURN (printing the bracket)
is then followed by pressing the ESC key, and the process is
propelled into either the \fIlearn\fR mode or the
\fIreprint\fR mode.
It should be noted that the ESC key can terminate alignment at
any point along the printer control sequence: if the last key before
ESC was a SPACE the final bracket is not printed and the width of
the margin is the number of spaces
typed since the previous output of the bracket.
If the document is not too sensitive to layout (as when
addressing an envelope), the alignment procedure can simply be
skipped by hitting the ESC key as the first control action.
.LP
The program puts the terminal in the \fIraw\fR mode, and in this mode
terminal interrupts are disabled.  Typing CONTROL-A during the
alignment process (except while writing a line of comment)
aborts the program immediately, restores the printer to its
normal operating mode, and resets the computer terminal.
The process may not be able to die however, if output was directed
to an inoperative printer.  While waiting to complete the I/O
task, the process can hang, and may need to be \fIkilled\fR from
another terminal.  Following this, the \fIreset\fR command should be
issued on the original terminal, to restore it to \fIcooked\fR mode.
.LP
Passing the adjustment procedure, a new form is
\fIlearned\fR and filled out under
keyboard control.  The basic unit of terminal input is a line,
with maximum width a function of the horizontal travel capacity of
the print head, not to exceed 248 characters.
Keyboard activity is immediately echoed to the screen.
Items or \fItokens\fR on a line are one of four types:
\fIspaces, controls, constants,\fR and
\fIvariables\fR.  Constants and variables are text strings.
Spaces and controls are input as single bytes
(each TAB is automatically converted to eight spaces).
Spaces (and expanded TABs)
are echoed to the screen as ``dot'' or ``bar'' markers on an imagined
ruler:
.LP
 . . . . | . . . . | . . . . | . . .
.LP
At the same time, an equal number of
true space characters (ASCII 32) are output to
the printer to force carriage movement and to
provide a visual
indication of the current horizontal position of the print head.
.LP
Control bytes that affect the printer
are converted ``on-the-fly'' to printer
escape sequences predefined for the printer in use.
Escape sequences
are immediately down-loaded to the printer, and effect switching
between character-sets or enable/disable other printer capabilities.
Printer control bytes
are not echoed to the line accrued on the screen.  That the program
has recognized these is made evident by highlighting the
appropriate control byte on a narrow ``control code menu'' at the
bottom of the screen.
.LP
CONTROL-H, DEL or BACKSPACE cause the print head to move to the previous
print column, while simultaneously erase the
``dot'' or ``bar'' to the left of the cursor on the screen
and move the cursor to the erased column.
Backing up in this manner
is possible all the way to the last byte of a
previous constant or variable, or to the beginning of an otherwise
empty line.  Note that while
backing up does not ``erase'' or deactivate
control commands already sent to the printer, control bytes
in the session record are automatically skipped backwards and
are in effect removed from the record.
.LP
The first ``printing'' character typed at the beginning of
the line or after
any sequence of \fIspaces, controls, constants\fR or
\fIvariables\fR, begins a constant and switches the input parser to
a ``collect text string'' mode.
Individual bytes of the constant are echoed to the screen
as they are typed, but the
constant is not output to the printer until a RETURN from the keyboard
signals that the constant is complete.  This allows the correction of
typos with the
BACKSPACE, DEL or CONTROL-H keys in the conventional manner.
The character-set of a constant
is the set of all ``printing'' characters and the SPACE character
(again, TABs automatically convert to eight spaces).
The RETURN at the end of the constant
signals only the end of the constant, not of
the line: the string may be followed by more \fIspaces,
controls, constants,\fR
or \fIvariables\fR.  The completed string is equivalent to an unchanging
horizontal field of data to be reprinted in an identical
position on future copies of the form.
.LP
Variable syntax is identical to that of constants.  But while constants
represent unchanging data, the text of a variable is expected to
be different on future copies of the form.
Variable definition begins when a CONTROL-V is typed at the
beginning of a line or following
any sequence of \fIspaces, controls, constants\fR or
\fIvariables\fR.
The user is immediately
prompted for a name for the variable, so that
the field can be referenced in the future.
Length of variable names is limited to 45 characters.
The character-set of the
name is once more all ``printing'' characters and SPACE, and the name
definition ends when the user types RETURN.
The name query is in a different area of the screen than the line
in construction;
neither the CONTROL-V or the name query disturbs the screen image of
the collected line.
After naming the variable, the cursor returns to its
former point in the line under construction, and input continues with
the current text of the variable.
Once again, text is echoed to the screen,
terminated with a RETURN, and printed identically to a
string constant.  A message advises the user to pad the
current value with spaces or TABs to the maximum
width of the target box: the print width
of future values is not allowed to exceed the present width.
.LP
Concurrently with the completion of each token,
the \fIspace, control byte, constant\fR or
\fIvariable\fR is entered into the session record.
Spaces and most control bytes (except BACKSPACE, process and screen
control bytes, CONTROL-L and RETURN)
are written as themselves; in the record
a printer control byte is not expanded to the printer's escape
sequence.
Constants are written to the record as ordinary text
(but without the \fInewline\fR that signified the end of the constant).
Variables are written
beginning with a CONTROL-V, followed by the user-given variable name,
a second CONTROL-V, the current string
of the variable possibly padded with spaces, and a trailing CONTROL-V.
.LP
The interactively composed line is terminated when a CONTROL-L or
RETURN is typed from outside the constant/variable collection
process, or when a CONTROL-U is typed anywhere on the line.
CONTROL-U is a mnemonic for \fIundo\fR; it returns
the process to the point where the assembly of the
line began.  The printer head is returned to the left margin without
line feed.  Characters already printed on the current line of
the form remain, but will be absent from the data
saved in the session record.
.LP
If the line is terminated with a CONTROL-L, a single
\fI``carriage return + line feed''\fR (CRLF)
sequence is sent to the printer.  If the line is terminated with
RETURN, eight consecutive CRLF sequences are sent to the printer.
.LP
Most dot matrix printers and electronic typewriters are capable of
computer controlled paper feed in increments of 1/48 inch.  It is
assumed that the control sequence for feeding paper in 1/48 inch
increments has been predefined for the printer in use
at the installation of
\fBuniform\fR, so that a CONTROL-L will cause only a very slight
advance of the form on the printer platen.  As RETURN 
gets expanded to eight successive line feeds, it produces a
paper advance of 1/6 inch, the width of a standard ``single spaced''
line.  During the \fIlearning\fR of the form then, RETURN will
cause a normal 1/6 inch
line feed; one or more CONTROL-L can be
typed for precise alignment of the text between some upper and
lower box boundaries.  If the printer can not feed paper at this
granularity, fitting text between vertical boundaries can be
considerably more difficult (however the algorithm and the
CONTROL-L/RETURN relation stay the same).
.LP
The line-terminating
CONTROL-L is saved in the session record as the normal \fInewline\fR
or \fIend-of-line\fR
character, and as such, will not be visible when using standard editors
to view the session record.
Eight \fInewlines\fR are recorded for a line-terminating RETURN.
Subsequent reprint sessions under \fBuniform\fR will reset the printer
to feed paper in 1/48 inch increments, and re-translate eight
\fInewlines\fR of the record to single spaced, 1/6 inch line feeds.
.LP
Thus, the saved data file is a perfectly ordinary
if somewhat sparse, ASCII text file with a few embedded
``control characters'' to bracket variables or to serve as printer
control flags.  CONTROL-A characters in the file begin comments;
the comment ends with the
\fInewline\fR terminator at the end of the line.
The file can be edited with conventional editors, in order to review
the saved data, to alter
recorded text, or to adjust layout.

.SH HINTS FROM A PRO
.in +.3i
.ti -.3i
\(bu \ \ \ Most printers use ``pin feed'' paper,
whereas most blank forms
do not have pin feed stripes.  If the printer can not
be set to ``friction feed'', or if the friction feed mechanism
is unreliable,
tape the blank form on top of a sheet of pin feed paper with matte
cellophane tape.  Lightweight tape should be used,
covering the entire left edge of the form.  This is
to prevent the print head from colliding with a protruding
paper edge, and tearing the form or damaging itself.  Do not tape up
the pin feed holes.  Afterwards, peel off the tape or cut
along the edges of the form.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ If the top edge of the form does not reach
the paper guide when the
printer head is lined up with the topmost box on the form, stick two
pieces of paper tape on the top of the form and fold down each one over
itself to form a ``tab'' or ``ear'' that will reach under
the rollers on the paper guide.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ Some machines will insist on moving the printer head to the left or
right boundary of an invisible ``print window'' after each
print activity.  This makes it impossible to visually
infer the horizontal location where the next byte would go.
A strip of plastic, a toothpick, or a piece of wire can usually be
affixed to the moving case of the print head (for example, taped to
the moving ribbon cartridge) in a way to point to the next print
position even though the head already returned to its left or right
window boundary.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ A couple of ``dry runs'' with just normal computer paper in
the printer provide good practice, and will instill the confidence
necessary for producing and printing arbitrary forms when
squeezed for time.
Mark a spot somewhere on the paper with a pen
to serve as corner of the top left box on a form.
Call \fBuniform\fR without a file name, and
follow the instructions on the screen for homing the printer head
to the spot you marked.  ``Fill out'' the imaginary form with
various information, don't hesitate to define some variables.
Then call \fBuniform\fR again, this time with the name of the record
of the previous session; rewind the paper back to the previous spot,
and attempt to print the copy directly over the original.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ \fILearning\fR a form represents a fair investment of effort.  If
you are filling out your only copy of the form as you \fIlearn\fR it,
you will have to be extra careful with the layout, because the
\fBundo\fR command will return the printer head to the beginning of
the line, but will not erase mistakes already printed in that line.
If you have access to a photocopy machine, copy the blank form, and
\fIlearn\fR it using the copy.  Similarly, you can use a copy to
verify that the file recorded during the learning session is correct,
before printing the data on the original form.
Minor mis-alignment problems in the recorded file are easy to fix
by editing the file and adding/deleting blank lines to change
vertical layout, or adding/deleting spaces to change the horizontal
positions of constants or variables.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ There is no penalty for recording text broken into
several small tokens instead of as one long token.  For example, a
Social Security number
can be split into three separate tokens to achieve a more precise
horizontal alignment on either sides of the pre-printed \fIdashes\fR.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ If you mistakenly began a string and
then erase all characters of the string
(by typing \fIbackspaces\fR), the process will still
remain in
the ``collect string'' mode until it receives the terminating
RETURN from the keyboard.  If the constant is empty at this point, it
is not recorded in the file of the session; input continues
normally, and BACKSPACE characters are not blocked by the erased
constant.  If the null string was the value specified for a variable,
the empty variable is output to the saved file, and BACKSPACE
characters will be blocked at the invisible variable boundary.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ Even if you remember the exact spot used to ``home'' the
printer head when creating the original, the horizontal
alignment of the copy will be off on occasion
by the better part of a character
width.  This usually is of no consequence, unless the printed data
is a single \fBX\fR checkmark typed into a character-sized
square.  To combat the problem, make it a practice to use
\fBXX\fR for a checkmark instead of \fBX\fR.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ Be careful with ``undo''-ing
lines in which you have transmitted an
escape sequence to the printer, or with \fIbackspacing\fR over printer
control codes.  The printer will still be
affected by the escape sequence (and may continue filling out the
original form in a compressed character-set for example);
but the control command will not get into the record, and
future copies may be misaligned (printed using the wider,
original character-set in the example).
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ The task of the variable mechanism of
\fBuniform\fR is to print changing data into unchanging
coordinates on the form.  On rare occasions the vertical layout
of the form may not be constant.  As an example, a line-oriented
medical questionnaire may begin with an informative list of visits
and corresponding dates, charges, etc.
to the medical facility; and depending on the number of visits,
the space for the user-supplied answers to questions
would get shifted lower and lower on the form.
An obscure feature in the \fInew variable value\fR collector
allows printing such
vertically variable forms.  When collecting a new variable value,
the recognized character-set is expanded by the CONTROL-L and
CONTROL-F characters, such that a CONTROL-L causes an immediate
1/48 inch line feed on the printer, and CONTROL-F causes an
immediate 1/6 inch line feed (RETURN could not be used for this here,
since it would signal the end of the variable).
A minimal-height form should be
chosen for creating the prototype, with a ``dummy'' variable
installed within the vertical sequence of line feeds at the
point where the form can be expected to ``stretch''.
At reprint time the printing process will be interrupted so
that the program can receive a new value for the variable.
Instead of responding with a string of text, the user can
issue paper feed commands, until the extra line feeds catch up
with the vertical expansion of the current version of the form.
.LP
.in +.3i
.ti -.3i
\(bu \ \ \ \fBuniform\fR may also see use in producing
``form letters'', electronic check writing,
computerized ``typewriter art'',
and in other printing endeavors requiring
fine control over and repeatability of print topology.
Less obvious applications may substitute
a different type of slave for the printer: \fBuniform\fR
could precisely and interactively tune a servo-mechanism 
in programming a robot, ``canning'' the instruction sequence
at the same time for automatic replay.

-- 
        Istvan Mohos
        ...uunet!pyrdc!pyrnj!hhb!istvan
        RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
======================================================================



More information about the Alt.sources mailing list