.bp
.ds F1 - % -
.ds Fd
.ds F3  ~
.ds Fl  Unit~III
.ds Fr  Module~II
.ds H1  ~
.ds Hl MP119
.ds Hr Introduction to UNIX
.PH "~~~~~~~~~~~~~~~~~MODULE~II~--~NROFF" 5 2 2 3
.PP 5
This module covers UNIT III objectives 4 and 5.
.PH "Objectives"
.PP
After completion of this module, you will be able to:
.L1 5 2 1
Use the proper command to gain access to nroff.
.L1
Display a file beginning at a specified page.
.L1
Terminate output after a specified page.
.L1
Control the length of the pause between each page of output.
.L1
Control page formatting:
.L2
page length
.L2
page mumbering
.L2
begin output on a new page
.E2
.L1
Control text placement on a line.
.L1
Control vertical spacing.
.L1
Determine line length.
.L1
Indent automatically.
.L1
Define and execute macros.
.L1
Define character strings.
.L1
Underline text.
.L1
Generate headings.
.L1
Obtain automatic numbering of pages, paragraphs
and lines.
.E1
.bp
.PH "Introduction~to~Nroff" 5 2 2 3
.PP 5
In this module, you will learn to format the text in your
files through nroff.  This feature facilitates and expedites
data entry.
.PP
Nroff is a text processor. (The term Nroff is short for
New Runoff.) It accepts lines
of text interspersed with lines of format control commands
and formats the text into a printable paginated document.
.PP
Nroff offers unusual freedom in document styling, such
as arbitrary style headers and footers; multiple automatic
sequence numbering for paragraphs, sections, etc.,
automatic indenting; and underlining.
.PP
The form of the command is:
.sp
.ti 15
nroff {options} <filenames>
.sp
Where "options" represent any number of optional arguments
(see below), and "filenames" represent the list of files to be
formatted. For instance,
.sp
.ti 20
nroff -o6- junk
.sp
will display the file "junk" beginning with the 6th page.
.sp 2
.PH "~~~~OPTIONS~~~~~~~~~~~~EFFECT"
.sp
.in 22
.ti -22
~~~~~-olist~~~~~~~~~~~Begin output at the first
page number listed, (whether
or not the page number is to
be printed), and print
all listed pages.
.sp
Example:~nroff -o8- junk
.br
will display the file "junk"
beginning with the 8th page.
.sp
Example:~nroff -o1,20 junk
.br
will display the first and
and twentieth pages of the
file "junk."
.sp
Example:~nroff -o3,5,8-13 junk
.br
will display pages 3,5,and  8
through 13 inclusive.
.bp
.ti  -22
~~~~~-nN~~~~~~~~~~~~~~Number the first output page N.
Example:~nroff -n3 junk
.br
will cause the first page displayed to be numbered
"3" instead of "1."
.ne 7
.sp 2
.ti  -22
~~~~~-s~~~~~~~~~~~~~~~Stop between pages.  The system
displays one page at a time.  You
must depress the return key after
each page is displayed, in order
to display the next page.
The command is as follows: nroff -s junk
.ti -22
~~~~~-T~~~~~~~~~~~~~~~~Informs nroff of the terminal type
so that it can take advantage of special features. The
specific options are:
.sp
.in +5
-T832~~~~~Anderson Jacobson AJ832
.br
-T100~~~~~Qualterm X100
.br
-T300Q~~~~GSI 300Q
.in -5
.sp
The terminal type default option is -T37 (Teletype Model 37).
.in 0
.sp
What will be the result of the following command:
.sp
.ti 20
nroff -s -o5-50 junk
.sp
Answer:
.sp 2
You're correct if you said the system will display pages 5 thru 50
one page at a time.
.ne 10
.PH "Nroff~Commands"
.PP 5
Nroff also provides several commands that are used
to enhance text formatting. These commands are typed
interspersed with lines of text.  All commands must begin
in the first position of a line. Otherwise, the command will
be interpreted as text.
.PP
Nroff is used in conjunction with another file, "tmac.nm."
This file contains a set of pre-defined macros which will
make life easier for you. What is a macro? We'll get to
that shortly. To access this file, put the following line as
the first line of your file:
.sp
.ti 20
\&.so /usr/lib/tmac.nm
.ne 10
.sp
Caution:~If this line is omitted, certain commands mentioned in
this unit will not be executed.
.ne 20
.sp
Example of an nroff file named "test":
.sp
.in 15
\&.so /usr/lib/tmac.nm
.br
\&.bp
.br
\&.ll 80
.br
\&.in 5
.br
This is an Nroff file which consists of Nroff commands and
lines of text.  The Nroff commands may be interspersed
with lines of text throughout the file.
.sp
.in -15
To display the file in its formatted form, type:
.sp
.ti 20
nroff -s test
.PH "Page~Control~Formatting"
.PP
The following commands are used to format the output page. They
may be placed throughout the text in your file.
.L1 5 2 1
page length (.pl)
.sp
This command allows you to specify the number of lines of text
to be placed on a page.  The form of the command is:
.sp
.ti 28
\&.pl 50
.sp
In this instance "50" indicates the number of output lines to place on each
page. This includes the nine lines used by the system for headers and footers.
Therefore, you must specify the number of lines of text to be placed on
each page, plus nine.
.sp
If this command isn't used, the system places 66 lines of output
on each page provided that many exist in the file.
.L1
Begin page (.bp)
.sp
This command, when encountered, causes the system to eject
the current page and begin a new page.  The form is:
.sp
.ti 28
\&.bp
.br
.ti 23
or
.br
.ti 28
\&.bp N
.sp
.ne 10
The second form, if used, causes the system to begin a new page and to
number the page using the specified number.  If the number
isn't specified, the system begins its numbering with 1.
.sp
.ti 24
Example: .bp 5
.sp
will cause the system to eject the current page and to number the new page
5.
.L1
Page~numbering~(.pn)
.sp
You're probably thinking, "Sure that's fine, but what do I do if
I want page numbering to begin at something other than 1, and I don't
want a new page?"
.sp
.ne 5
This is where th 'pn' command proves its usefulness.  The form
of the command is:
.sp
.ti 28
\&.pn N
.sp
where "N" indicates the number to use to begin numbering the pages.
Here is an example:
.sp
.ti 28
\&.pn 20
.sp
Can you think of another way this can be accomplished?
Answer in the space provided.
.sp 3
Sure you can, page numbering can be specified directly in the
nroff command, as shown below:
.sp
.ti 25
nroff -n20 junk
.sp
.L1
Page offset (.po)
.sp
This command is used to prepare spaces to each output line.
The command format is:
.sp
.ti 28
\&.po N
.sp
where "N" indicates the number of spaces to place before each line.
That is, the page image is moved 'N' spaces to the right.
.E1
.sp 2
.in 9
.ti -9
Notes:~1.The ".po" command  should  be  preceded by a ".br"
if it is placed between lines of text.
.sp
.ti -9
~~~~~~~2.The no-break character (') can  also  be  used
with any of these commands.
.in -9
Ready to check your knowledge?  Do the following exercises.
.PH "Exercise"
.sp
Create a file from the following text:
.PP
You have been approved by the Department to take one or more courses
at a local college or university.  Your tuition and laboratory fees (2/3
in the case of the Department's after-hours program) are paid by contract.
You must pay all other fees (matriculation, registration, etc.) and
purchase your own books and supplies.
.PP
You are expected to comply with all DOD and university regulations
and to earn satisfactory grades.  In addition to meeting these requirements,
you must maintain at least a C+ average in order to be eligible for
continued consideration for agency tuition assistance.
.sp 2
Note: Did you remember to include this line?
.sp
.ti 18
\&.so /usr/lib/tmac.nm
.sp
.L1 5 2 1
Display the above file using nroff, such that:
.L2
Each paragraph appears on a separate page.
.L2
Page numbering begins with 3.
.L2
A pause is generated before each page.
.L1
Display the file again, such that:
.L2
5 lines of text are placed on each page.
.L2
The last half of the file is displayed with an offset of 15.
.E2
.E1
.bp
.PH "Text~Placement~Control"   5 2 2 3
.PP  5
The next commands allow you to determine how and where the output
lines are to  appear on the page.  These commands eliminate the task of
setting margins, centering lines, spacing to indent, spacing to generate
blank lines within the text, etc.
.PH "Break~(.br)"
.PP
The ".br"  command causes the system to begin a new line with the
text following this command. Suppose your directory contains the
following file, "junk":
.sp
.in 18
Now is the time
.br
for all men
.br
to come to the aid
.br
of their country.
.in -18
.sp 2
And, you issue the command:
.sp
.ti 20
% nroff junk
.sp
the system will display:
.sp
Now is the time for all men to come to the aid of their country.
.PP
The system will automatically place characters on a line until the line
is filled unless otherwise directed, such as:
.sp
.nf
		  now is the time
		  .br
		  for all men
		  .br
		  to come to the aid
		  .br
		  of their country.
.fi
.sp
Now if you issued the command:
.sp
.ti 20
% nroff jujk
.sp
the results displayed would be:
.sp
.in 18
Now is the time
.br
for all good men
.br
to come to the aid
.br
of their country.
.sp 3
.bp
.PH "Fill~output~lines~(.fi)"  5 2 2 3
.PP 5
This command places the system in the "Fill Mode" which directs the
system to place characters on the output line until the maximum number of
characters has been placed there.  This is the action normally taken by
the system. Therefore, you would use this command only if this condition
needed to be reactivated.
.sp
.in 6
.ti -6
Note:~The number of characters to place on a line depends on
the value of the line length parameter. This parameter is
normally set to 65; however, it may be reset by you.
.in -6
.PP
Now, before you look at an example, take a look at the next command.
.PH "No-fill~output~lines~(.nf)"
.PP
This command causes subsequent output lines to be displayed exactly
as they appear in the file.  No regard is given to the maximum line length.
.sp
For example, when your file contains
.sp
.in 18
Now is the time
.br
for all good men
.br
to come to the aid
.br
of their country.
.br
\&.nf
.br
Now is the time for
.br
all good men to come
.br
to the aid of their
.br
country.
.br
\&.fi
.br
Now is the time
.br
for all good men
.br
to come to the aid
.br
of their country
.sp
.ti -18
The results will be:
.sp
.fi
Now is the time
for all good men
to come to the aid
of their country
.nf
Now is the time for
all good men to come
to the aid of their
country
.fi
Now is the time
for all good men
to come to the aid
of their country
.in 0
.sp 3
Got the idea?  the ".nf" command has a effect similar to the ".br"
command doesn't it?
.PP
If you can't discern how the results were obtained, please re-read
the preceeding two sections.
.PH "Adjusting~output~lines~(.ad)"
.PP
Nroff even has a command which can be used to left-adjust, to
center, or to right-adjust your text.  The command is:
.sp
.ti 25
\&.ad c
.sp
where "c," the adjustment type character, is used to indicate the manner
in which the text is to be adjusted on the output line.
.sp
If the adjustment type character is a/an:
.sp
.nf
	1. "r," the text will be right-adjusted, aligned
	   and the left margin will be ragged; e.g., ".ad r";

	2. "c," the text will be centered -- both margins
	   will be ragged; e.g., ".ad c";

	3. "n," the normal (default) is restored -- both
	   margins will be adusted or even; e.g.,"ad n."
.fi
.sp
.in 6
.ti -6
Note:~The "Fill Mode" must be turned on before the system will recognize
and execute the adjustment command.
.in -6
.PH "Noadjust~command~(.na)"
.PP
This command turns the adjustment off.  The text following will be
left-adjusted. That is the left margin will be even and the right margin will
be ragged.  Output line filling will occur only if the "Fill Mode" is
turned on.
.PH "Centering Output Lines (.ce n)
.PP
This command is also used to center output lines. However, unlike the
adjustment command, the lines are centered just as they appear in the file -
no line filling takes place. "n" denotes the number of lines to be centered.
If "n" isn't specified, one line is centered.
.PH "Vertical~Spacing"
.PP
As you have seen, the system will automatically single space your
output. But, what about double or triple spacing?  Sure, you can hit the
RETURN KEY two or three times in succession, but wouldn't it be much
easier if you could program your file such that the system will perform
automatic vertical spacing?
.PP
Well, you can by using the "ls" (line spacing) command which has
the form:
.sp
.ti 25
\&.ls n
.sp
where "n" denotes the number of lines, less one, that the system will
leave blank following each output line. For example, you are going to
display the following file using nroff:
.sp
.in 18
\&.so /usr/lib/tmac.nm
.br
\&.ls 3
.br
Now is the time
.br
for all young men
.br
to come to the aid
.br
of their party
.in -18
.sp
The result will be:
.in 18
.ls 3
Now is the time
.br
for all young men
.br
to come to the aid
.br
of their party
.ls 1
.in -18
.sp
You're probably thinking, "that's fine, if you want the whole file to be
evenly spaced." Not so; take a look at the following file:
.sp
.in 18
\&.so /usr/lib/tmac.nm
.br
\&.nf
.br
\&.ls 3
.br
Now is the time
.br
for all young men
.br
\&.ls 1
.br
to come to the aid
.br
of their party
.in -18
.ne 10
.sp
What do you think the results will be?  Write your answer below.
.sp 2
You're absolutely correct, if your answer agrees with:
.sp
.nf
		  Now is the time


		  for all young men


		  to come to the aid
		  of their party
.fi
.sp
Just reuse the "ls" command with a different value and you change the
number of blank lines inserted after each output line.
.PH "Blocks~of~vertical~space"
.PP
You may also direct the system to generate blocks of space within
your file. That is, you can cause several blank lines to be inserted at
cause points throughout the file. Thus, you can vary the distance between
the heading and the text or to cause certain items, such as examples,
to be conspicuous. The form of the command is:
.sp
.ti 25
\&.sp n
.sp
where "n" indicates the number of lines to leave blank when this command
is encountered. Here is an example of how the command is used.
.sp
.in 18
\&.so /usr/lib/tmac.nm
.br
This is my heading
.br
\&.sp 4
.br
This is my text
.in -18
.sp
This would cause 4 blank lines to be inserted between the heading and
the first line of text.
.sp
.in 11
.ti -11
Notes:~(1)~You must reuse this command each time you want a block
of lines inserted.
.sp
.ti -11
~~~~~~~(2)~If "n" isn't specified, it is assumed to be 1.
.in -11
.PH "Control~Characters"
.PP
Let's pause a moment to discuss two very significant
characters before beginning our discussion of the nroff commands
.PP
The period (.) and the apostrophe (') are referred to as
control characters.  All nroff commands begin with either the "."
(break character) or the "'" (no-break character). Any line
beginning with either of the characters is called a control line.
.PP
The "." causes the command which follows to be executed
at the point it is encountered within the text. This may cause
the system to output a partially filled line. Let's assume you have
the following text:
.sp
.nf
 Come one, come all, the time is now. Now is the time for all
 .br
 to come to the aid of their country.
.fi
.sp
.in 6
.ti -6
Note:~"br" indicates that the next line of text begins a new line;
otherwise  the  system will treat all lines as one continous
stream.
.in -6
.PP
Now suppose that the line before the ".br" is too long to
fit on the current output line. Let's see how the system handles
this:
.nf
.sp
come one, come all, the time is now.  Now is the time
for all
to come to the aid of their country.
.fi
.PP
Okay, let's change the ".br" to "'br" and see what happens.
The text would now be displayed as:
.sp
.nf
come one, come all, the time is now. Now is the time
for all to come to the aid of their country.
.fi
.PP
The  "'"  suppresses  the  output   of   a
partially   filled  line  until  after  the
command  following   the   "'"   has   been
executed. Before continuing with the next command,
try to answer these questions correctly.
.ne 25
.PH "Exercises"
.sp
Differentiate between using:
.sp
.L1 5 2 1
".br" and ".sp" to begin a new line.
.sp
~~~answer:
.L1
".ls" and ".sp" to obtain vertical spacing.
.sp
~~~answer:
.L1
".ad c" and ".ce".
.sp
~~~answer:
.L1
".br" and ".nf".
.sp
~~~answer:
.E1
.bp
.PH "Answers"  5 2 2 3
.sp
.L1 5 2 1
".sp" causes a blank line to be inserted in addition to beginning a new
line; ".br" just begins a new line.
.L1
".ls" can be specified once and the system will insert that number of blank
lines after each output line within the file.  ".sp" must be specified each
time blank lines are to be inserted.
.L1
".ad c" will center lines with line-filling taking place; ".ce" centers
lines without line-filling.
.L1
".br" must be specified before each line which is to begin a new line; ".nf"
needs to be specified only once for an unlimited number of lines (until the
".fi" command is executed).
.E1
.in 4
.ti -4
****If you answered any of these questions incorrrectly, please re-read
the appropriate sections.
.in -4
.PH "Line~length~(.ll)" 5 2 2 3
.PP
Another nroff nicety is being able to specify the
maximum length of each line in your file, which if not otherwise
specified is 65 characters. At ten characters per inch, this
amounts to 6 1/2 inches.
.sp
The command used to change the line length is:
.sp
.ti 25
\&.ll n
.sp
where "n" denotes the maximum number of characters to place on a line.
There are no restrictions on the number of times the line length may
be changed within a file; therefore,
.sp
.in 25
<text>
.br
\&.ll 80
.br
<text>
.br
\&.ll 132
.br
<text>
.br
\&.ll 65
.br
<text>
.in -25
.sp
is quite valid.
.PH "Automatic~indenting~~(.in)"
.PP
Automatic indenting may also be obtained by using the ".in" command.
Just think how using this command will accelerate data entry. No
more counting and spacing over to a certain column or trying to
recall how many spaces to indent to ascertain proper alignment.
As an example:
.sp
.ti 25
\&.in 15
.sp
will indent each subsequent line 15 spaces until the command is
re-used with a different value.  Now you try it.  Format the
following paragraph such that the first line is indented 10
spaces and the succeeding lines 5 spaces:
.sp
.in 10
Nroff is the program to really utilize,
.br
it eliminates many tedious task to your surprise.
.br
Not only does it help you to economize,
.br
your time,your effort, and likewise;
.br
but brings satisfaction to your boss' eyes.
.br
Which can be only good, I would surmise.
.in -10
.sp
Put your answer in the space provided.
.sp 3
You're  correct if your answer is:
.sp
.in 10
\&.in 10
.br
Nroff is the program to really utilize,
.br
\&.in 5
.br
it eliminates many tedious task to your surprise.
.br
Not only does it help you to economize,
.br
your time, your effort, and likewise;
.br
but brings satisfaction to your boss' eyes.
.br
Which can be only good, I would surmise.
.in -10
.ne 10
.PP
Okay, let's continue.  Do you know that you can also indent just a single
line? Yes, you can by using the ".ti" (temporary indent) command.
Let's illustrate its use by referring to the above problem and
indenting lines 1,3, and 5.
.bp
.sp
This task is accomplished in the following manner:
.in 5
\&.in 5
.br
\&.ti 10
.br
Nroff is the program to really utilize,
.br
it eliminates many tedious task to your surprise.
.br
\&.ti 10
.br
Not only does it help you to economize,
.br
your time, your effort, and likewise;
.br
\&.ti 10
.br
but brings satisfaction to your boss' eyes.
.br
Which can be only good, I would surmise.
.in -5
.sp
.in 10
.ti -10
Note:~(1) All lines will be indented 5 spaces unless
directly preceeded by the "ti" command.
.sp
.ti -10
~~~~~~(2) The .ti command can be used with the plus(+) and minus(-)
symbols to temporarily increase or
decrease the indent a specified number of spaces from the current
indent.
.in -10
.PH "Macros"
.PP
Macros afford you a tremendous amount of flexibility
and control over the order of execution of "nroff" commands within
your files.
.PP
A macro is a named  set of kne or iore lines that iay be invkked
when the name is referenced or by having reached a specified line on
the page*
.PP
The set of lines used to compose the macro may be command
lines or textual lines.  Macro names are arbitrarily choosen and
are one or two characters long.
.PH "Define~Command"
.PP
Macros are defined by using the "define" command which has the
following form:
.in 20
.sp
\&.de <name>
.br
<commands/text>
.br
\&..
.in -20
.sp
where ".de" defines the macro whose name is "<name>."  Following the
macro definition is the commands /text to be contained within the
macro. ".."  ends the macro definition. Here is an example of the
use of the "define" command.
.sp
.ne 10
.in 25
\&.de xx
.br
\&.pl 50
.br
\&.nf
.br
\&.ls 2
.br
\&..
.in -25
.sp
Only when the macro "xx" is invoked will the commands contained
within be activated.  Now the question is, how can a macro be
invoked?  A macro may be invoked by a macro reference or by setting
a "line trap."
.PH "Macro~Reference"
.PP
A macro is invoked when the name of the macro is referenced.
For instance, to invoke the macro in the above section, you would place
the command, ".xx," just before the text on which the commands in the
macro "xx" are to be applied.
.PH "Line~Traps"
.PP
The second method of invoking a macro is by setting a line trap.
Don't panic! This isn't as awesome as it sounds.  A "line trap" is just
a command which directs the system to invoke a certain macro when a
specified line on the page is reached. Here is an example:
.sp
.ti 25
\&.wh 5 xx
.sp
This reads, when line 5 is reached invoke macro "xx."  If the number
specified is 0 or positive, it refers to the top of the page.  The
number 5 means the fifth line from the top of the page.  What do you
think 0 refers to? Answer below.
.sp 3
That's correct, 0 refers to the top of the page.  Negative numbers
may also be used to reference the bottom of a page. Hence, -7 means
the seventh line from the bottom of the page.
.PP
The ".wh" command is usually placed at the beginning of a file
following the macro definitions.  Once set, a line trap will be
automatically executed for each subsequent page.  Also, more than
one line trap may be set referring to the same macro. Here is how
it could be done:
.ne 15
.sp
.in 20
\&.wh 0 zz
.br
\&.wh -7 zz
.br
\&.de zz
.br
\'tl ''UNCLASSIFIED''
.br
\&..
.in -20
.sp
.ne 5
This would cause the word 'UNCLASSIFIED' to be centered at the
top and at the bottom of each output page.
.sp
.in 10
.ti -10
Note: (1)~The command ".tl" left adjusts, centers and right adjusts
within three fields. The three fields are defined by single
quote marks. This command will be described in more detail at a
later point.
~~~~~~(2)~A macro is redefined when its name is used in
a later "define" command.
.in -11
.PH "Arguments"
.PP
Textual values may be passed to a macro to be displayed at the
time the macro is invoked.  These values are referred to as arguments
and may be modified each time the macro is called.  Let's look at the
following example to more clearly explain arguments:
.sp
.ti 18
\&.de A
.br
.ti 18
Today is \\\\$1 the  \\\\$2 of \\\\$3
.br
.ti 18
\&..
.sp
where "\\\\$1,\\\\$2,\\\\$3" represent arguments.  There may be as many as
nine arguments in a macro.  The values to be substituted for these
arguments are passed in the macro reference command. Look at the following
example:
.sp
.ti 18
\&.A Tuesday 4th July
.sp
This would display the line:
.sp
.ti 15
Today is Tuesday the 4th of July
.sp
You will notice that the first value replaces the first argument, the
second value the second argument, etc.
The next time the macro "A" is called, different values may be substituted
for the arguments.
.sp
.in 6
.ti -6
Note:~The substitution values in the macro reference are separated
by a blank. Therefore, if a value contains blanks, it must be
enclosed in double quote marks. Here is how it is accomplished:
.in -6
.ne 15
.sp
.in 20
\&.de zu
.br
Date: \\\\$1
.br
\&.br
.br
To: \\\\$2
.br
\&.br
.br
From: \\\\$3
.br
\&.br
.br
Subject: \\\\$4
.br
\&..
.br
\&.zu "Nov 27, 1977" E53 E5 Promotions
.in -20
.sp 2
.ne 8
.in 6
.ti -6
Note:~If the desired substitution values are too long to fit on one
line, type "\\ <carriage return>" (concealed new line character) and
continue to the next line. The last character on the line to be
continued should be "\\".
.in -6
.PH "Defining~character~strings"
.PP
Another beneficial feature is called character strings. It is
especially useful if you have to type a label or some other
identification tag several times throughout the file. A character string
is very similar to a macro. That is, it requires a name which is one or
two characters in length; and it may be referenced any number of times
even thought it is defined only once. A character string is defined by
using:
.sp
.ti 20
\&.ds <name> string
.sp
where "<name>" is the name of the character string and "string" is the
characters used to form the character string.  After the character string
has been defined, it may be referenced by:
.sp
.nf
	       \\*<1-character name>    eg.\\*A
		      or
		\\*(<2-character name>   eg. \\*(AB
.fi
.sp
Let's assume that you are typing a report  consisting of domestic
messages, and each message contains a code which indicates whether
the message was sent or received by the United States. You must
interpret the code by printing either "sender" or "receiver" at the
end of each message.
.bp
.PH "~~~~~~~~~~~solution:"
.sp
.nf
			|
			|
			.ds s sender
			.ds re receiver
			|
			|
			<message received by the U.S.>
			\\*(re
			<message sent by the U.S.>
			\\*s
.fi
Note: Of course, the longer the string, the greater the benefits.
.ne 35
All right, let's review your progress. Do the following exercises.
.PH "Exercise"
.L1 5 2 1
Take the file employed in the exercise on page 47 (adding the
information introduced in item c (below) and format it as follows:
.L2
The word "SECRET" centered at the top and bottom of each page.
.L2
Your name, organization, and secure phone number on the next
output line.
Note: Use arguments to pass the information
.L2
The following text is double-spaced and centered. Also,
display  "this  line is encoded text," before each line
containing an "i."
.sp
.nf
text:    Blue    Qoqz    Poue    zekf
	Jogw    newk    fikd    meth
	cikf    vebi    fewr    wunq
	virx    fikd    wegn    wudg
	holb    humb    nydn    hiof
	wyuw    kykw    wube    gawr
	wyln    qabo    gyuk    blue
.fi
.L2
Each line of text is placed on a separate output line.
.E2
.L1
Display the file constructed in #1 using nroff.
.E1
.sp
Compare your solution with the one on the following page.
.bp
.PH "Solution to the Exercise"
.sp
.nf
	     .wh 0 zz
	     .wh -7 zz
	     .de zz
	     'tl ''SECRET''
	     'sp 2 (leaves blank spaces after classification)
	     ..
	     .de za
	     Name:\\$1
	     .br
	     Organization:\\$2
	     .br
	     Secure Phone:\\$3
	     .br
	     ..
	     .za ''Your Name'' Organization Phone
	     (text from previous exercise is entered here)
	     .sp (assures that the end of preceeeding
		  text is not operated upon by the follow-
		  ing commands)
	     .ls 2
	     .ad c
	     .ds i This line is encoded text
	     .nf

	     blue    qoqz    pove    zefk
	     \\*i
	     jogw    newk    fikd    meth
	     \\*i
	     cikf    vebi    fewr    wunq
	     \\*i
	     virx    fikd    wegn    wudg
	     \\*i
	     holb    humb    hiof    nydn
	     wyuw    kykw    wube    gawr
	     wyln    qabo    gyuk    blue
.fi
.sp 2
.in 6
.ti -6
Note: ".br" could have been used following each output line
instead of using the ".nf" command.
Also, your solution does not have to be identical to this
solution to be correct.
.bp
.PH "Underlining text (.ul)"
.PP
Underlining can be achievied by backspacing and overstriking
with the desired character; however, this method is not only time
consuming but may cause alignment problems if the line has to be
modified.  The underline command will automatically underline
each word within the specified line.  The form of the command is:
.sp
.ti 25
\&.ul <n>
.sp
where "<n>" denotes the next n lines.  If "<n>" is omitted, only the
next line is underlined.  As an example, suppose you wish to underline
the heading in the last exercise; the file could be modified thus by:
.nf
		    .de zz
		    .in 24
		    \\\\$1 \\\\$2 \\\\$3
		    .sp 5
		    .ul
		    encoded lines
		    .br
		    ..
.fi
.sp
.in 6
.ti -6
Note: On a CRT Terminal (Delta Data or Superbee)
the system will display only the character used for the
underlining, not the characters being underlined
unless routed to the printer.
.PP
An alternative to routing the output to the printer would be
to route it through the "br" program; this causes the underlined lines
to appear highlighted. (Example: nroff <filename>|br)
.PH "Exercise"
.sp
.L1 5 2 1
Modify your solution to the  problem  in  the  previous
section  to  reflect  the  insertion  of  the underline
command.
.L1
Display the file using nroff, nroff with br, and nroff with opr.
.E1
.bp
.PH "Generating~Titles" (.tl)
.PP
The ".tl" command is used to generate titles or headings
that will be automatically right-adjusted, left-adjusted, or centered.
The form of the command is:
.sp
.ti 17
\&.tl 'left'center'right'
.sp
where the single quote is the field delimiter and left, center, and right
are character strings.  Okay, suppose you want to generate a header
which displays the "date" to the left; the "title of the document" in the
center; and "your organization" to the right, then you would form the
title command in the following manner:
.sp
.ti 14
\&.tl '06/12/78'encoded lines'E53'
.sp
now, let's form the header such that "encoded lines" is omitted.
.sp
.ti 18
\&.tl '06/12/78''E53'
.sp
The above command would left-adjust the date and right-adjust the
organization designator.
.sp
what will be the results of the following?
.sp
.nf
		  .de hd
		  .tl '06/12/78''E53'
		  .sp 3
		  .tl ''encoded lines''
		  ..
		  .wh 0 hd
.fi
.PP
Let's see how you did.  If your answer is: the system will display
the date and organization at the top of the page, and the title line
centered 3 lines from the top, you are quite observative.  If your
answer differs, it is probably with the second header; so let's closely
examine it.  The first two adjacent single quotes indicate that there is
no left string to be displayed; therefore the field is skipped.  Next
the center string is displayed in the center of the line, and the right
field is skipped because of the next two adjacent quotes.
.PP
Now try another one.  Where will the date be displayed when the
following command is executed?
.sp
.ti 20
\&.tl '''06/12/78'
.sp
At the right -- by george, you've got it.
.sp
.in 10
.ti -10
Note: (1) Any character may  be used as the field delimiter.
.ti -10
~~~~~~(2) The title command may appear inside a macro or outside a
macro; when outside a macro the title command should be directly
preceeded a ".br".
.in -10
.PH "Page~number~option"
.PP
You can direct the system to display the current page number
by using a "%" in the title command. For instance,
.sp
.ti 18
\&.tl '06/12/78''page %'
.sp
will yield:
.sp
.in 10
06/12/78~~~~~~~~~~~~~~~~~~~~~~~~page 1
.in -10
.sp
The page number will be incremented by 1 with each succeeding
page.  You now have the page number displayed at the top and
at the bottom of the page.
.sp
.in 6
.ti -6
Note: The "%" may appear in either of the three fields, not only the
right field.
.in -6
.sp
Now let's determine how to use the page number option.
.sp
.nf
		  Example:.de xx
			  .tl '''page %'
			  ..
			  .wh 0 xx
			  .wh -7 xx
.fi
.sp
will display the page number at the top and at the
bottom of the page.
.PH "Date~Option"
.PP
You can direct the system to display the current date
automatically by referring to the following pre-defined names:
.sp
.in 20
mo - current month
.br
dy - current day
.br
yr - current year
.in -20
.ne 10
These names are referenced in the following manner:
.sp
.in 25
\\\\n(mo
.br
\\\\n(dy
.br
\\\\n(yr
.in -25
.sp
Now let's reference the above in the title command.
.sp
.ti 10
\&.tl '\\\\n(mo-\\\\n(dy-\\\\n(yr''page-%-'
.sp
would yield.
.sp
.ti 10
5-24-78~~~~~~~~~~~~~~~~~~~~~~~~~page-1-
.sp
This assures that whenever the file is displayed, the current
date will appear in the header.
.sp
.in 6
.ti -6
Note:~The hyphens are not required in the format; they are
used only as  separators. Any character or group of characters
could also have been specified, for example .tl 'Today is:
.in +5
.sp
\&.tl 'Today is:\\\\n(mo/\\\\n(dy/\\\\n(yr'''
.br
would yield
.br
Today is: 5/24/78
.in -11
.PH "Character~Translation~(.tr)"
.PP
Nroff really outdid itself with this feature. You can
actually type one character and have the system display another
character in its place.  This feature could be an invaluable tool
to the analyst.The form of the command is:
.sp
.ti 23
\&.tr abcd....
.sp
where "a" will be displayed as "b"; and "c" will be displayed as "d,"
etc.  If an odd number of characters is specified, the last one will
be displayed as a space.  A common use of this command is to provide
nonadjustable spaces.  Hold it! Don't lose your cool, an explanation
follows.  When the fill mode is turned on, the system will sometimes
throw in additional spaces in order to fill the line with the
specified maximum number of characters, or a line may have to be
continued because it exceeds the specified maximum line length.  In
either case the above actions are performed only where a space is
present. Therefore, if you don't wish to have certain words or
phrases separated by more than one space, you could use the ".tr/"
command, ".tr/ ". Now any place you didn't want extraneous spaces or
an interruption you would place a "/". The following shows what is
meant:
.sp
.in 20
Mr/Edward/Joness
.br
fig./25
.br
2/+/x/=/y
.in -20
.sp
Here a space is displayed each time a "/" is encountered. Additionally,
the "/" used as a separator causes the system to interpret
any number of words or symbols as a single entity so they will not be
moved apart nor split across two lines.
.sp
Now, analyze the following:
.sp
.ti 25
\&.tr iIaA
.sp
Put your answer here.
.sp 3
Is your answer, "All lower-case i's  and a's will be displayed as
upper case I's and A's"? If so, very good. If your answer differs,
please review this section.
.tr #~
.in 6
.ti -6
Note: Many macro packages, such as "nm," "mm" and "ms",  use the convention
of # as a non-adjustable space. That is, the line:
.sp
.ti 20
\&.tr #
.sp
appears in each package. More will be said about this feature at
a later point.
.tr ~
.in -6
.PH "Defining~Tabs"
.PP
Text to be columnized doesn't present a problem to
nroff.  It provides commands which allow you to establish tab settings.
They are:
.sp
.in 23
\&.ta n,...
.br
\&.fc a b
.in -23
.sp
The "ta" command is used to specify the tab stop settings, as shown below:
.sp
.ti 22
\&.ta 5,10.15,...
.sp
The above command sets tab stops at every 5 positions.  The ".ta"
command, is used in conjunction with the ".fc" command, which describes
the format of the text.
.bp
.PP
Let's digress a moment.  First of all, the text has to be formatted
into fields.  The "a" in the ".fc" command indicates the character being
used to delimit the fields.  This character precedes and follows each
field of text.  To further clarify, an example is in order.
.ne 15
.PP
Let's assume that you have a file containing the following
information on messages:
.sp
.nf
	To      From    Timeup  Timedown        Date

Your file would be formatted as follows:

	.ta 10,20,30,40,50
	.fc /
	.nf
	/ABC//DEF//0900//0950//060978/
	/DEF//GHI//1005//1010//061278/
	/ABC//GHI//1240//1300//061578/
.sp
When displayed, the above file would yield:
.sp
       00000000011111111112222222222333333333344444444445
col.   12345678901234567890123456789012345678901234567890
.sp
       ABC      DEF       0900      0950      060978
       DEF      GHI       1005      1010      061278
       ABC      GHI       1240      1300      061578
.sp
.fi
.PP
Notice that the system left-adjusts the fields of text within  the
specified tab-stops.  The fields of text can also be right-adjusted
or centered by using "b," the other parameter in the "fc" command.

.PP
"b" is referred to as the padding indicator, so called because
it is used to indicate on which side of the field the extra spaces are
to be placed.
.sp
.nf
		    Example: .fc / ?
			     /?ABC/
.fi
.sp
In this case, the field would be right-adjusted; whereas:
.sp
.ti 25
/?ABC?/
.sp
would cause this field to be centered
.PP
The ".ta" command may be used to cause all text to begin in the same
column.  This is accomplished by specifying only a single value in
the ".ta" command, and by depressing the tab key before typing the line
of text.  The padding character should not be used since it will be
interpreted as text, and consequently displayed.
.sp
.ne 10
.in 10
.ti -10
Notes:(1) The default tabs are 9, 17, 25 ... .
.ti -10
~~~~~~(2) A total of 20 tab stops may be set, and the values
may be separated by spaces, commas, or any other
nonmumerics.
.ti -10
~~~~~~(3) The delimiter and padding characters may  be  any
arbitrarily chosen characters.
.ti -10
~~~~~~(4) Certain system programs, such as the RAND editor,
will remove tabs and replace them with the appropriate
amount of spaces.
.in -10
.PP
We've covered a lot of ground. Do you think you're ready for the
Module Test? If so, look over the objectives for this module.
Review any material you're uncertain of. Then, scan the "Command
Summary" sheet. When you are ready, take the module test. It
begins on the page following the "Command Summary" sheet.
.bp
.PH "~~~~~~~~~~~~~~~~~Command~Summary"
.PH "~~~~~Nroff~{options}~<filenames>"
Note: The options are -olist, -nN, -s, -T <terminal name>
.sp
\&.so/usr/lib/tmac.nm (access to "tmac.nm" program)
Control characters: the period (.) and the apostrophe (')
.sp
.L1 5 2 1
\&.br (Break command)
.L1
\&.pl (Page length)
.L1
\&.bp (Begin page)
.L1
\&.pn (Page numbering)
.L1
\&.po (Page offset)
.L1
\&.fi (Fill output lines)
.L1
\&.nf (No-fill output lines)
.L1
\&.ad (Adusting output lines)
.L1
\&.ad c (Text centered)
.L1
\&.ad r (Text right-adjusted)
.L1
\&.ad n (Both margins adjusted)
.L1
\&.na (No adjust)
.L1
\&.ce n (Center output lines)
.L1
\&.ls n (Line spacing)
.L1
\&.sp n (Vertical spacing)
.L1
\&.ll n (Line length)
.L1
\&.in n (Automatic indenting)
.L1
\&.ti n (Temporary indent)
.L1
\&.de <name> (Define command; defines macro "<name>.")
.br
~~~~~~<commands/text>
.L1
\&.wh n <name> (line trap; invokes macro "<name>.")
.L1
\\\\$1, \\\\$2, \\\\$3,etc (Arguments used with macros. There may
'br
be as many as nine with one macro.)
.L1
\&.ds <name> string (defining a character string)
.L1
\&.tl '<name>' (Title command)
.L1
\&.tl '<name>'page%' (Title command with page no.option)
.L1
\\\\n(mo
.br
\\\\n(dy  } Date options
.br
\\\\n(yr
.L1
\&.tr (Character translation)
.L1
\&.ta n (Tab stop settings. Used with the ".fc" command.)
.L1
\&.pl (Page length)
.L1
\&.bp (Break page)
.L1
\&.pn (Page numbering)
.L1
\&.po (Page offset)
.L1
\&.br (Break)
.L1
\&.fi (Fill output line)
.L1
\&.nf (No fill output lines)
.L1
\&.ad c (Adjusting output lines)
.L1
\&.na (No adjust)
.L1
\&.ce (Centering output lines)
.L1
\&.ls (Line spacing)
.L1
\&.sp (Vertical space)
.L1
\&.de (Macro definition)
.L1
\&.in (Indent)
.L1
\&.ll (Line length)
.L1
\\\\$n (Argument definition)
.L1
\&.ds <name> <string> (Character string definition)
.L1
\&.ul (Underline a line)
.L1
\&.tl (Title definition)
.L1
%   (Current page number)
.L1
\\\\n(mo (Current month)
.L1
\\\\n(dy (Current date)
.L1
\\\\n(yr (Current year)
.L1
\&.tr (Character translation)
.L1
\&.ta & .fc (Set tabs)
.E1
.bp
.PH "Module~II~Test"
.sp
DIRECTIONS: Use only the "Command Summary" sheet as an aid in taking
this test.  Minimum passing score is 11 out of 16 correct.
.sp
.L1 5 2 1
What command is used to gain access to the nroff program?
.L1
For what purpose in the nroff command used?
.L1
The command:"nroff -o1-10 junk" will:
.L2
display the file, junk, beginning with page 10.
.L2
display the file, junk, ending after page 10.
.L2
display the file, junk, numbering the first output page as 10.
.E2
.L1
Give a brief explanation of the following commands:
.br
.L2
 .bp 8
.br
.L2
 .pn
.br
.L2
 .po 8
.E2
.L1
Write the command which will cause a maximum of 40 lines to be placed
on each page.
.L1
List 3 commands which will cause the "fill line mode" to be
ineffective.
.br
~~~~~~~~~a. _______
.br
~~~~~~~~~b. _______
.br
~~~~~~~~~c. _______
.sp
.L1
Write 2 commands used to center output lines, and state how they
differ.
.br
~~~~~~~~~a. _______ b. ____________
.br
~~~~~~~~~Differences: _____________________________________
.L1
Which of the following will cause double spacing:
.br
	(a) .ls 2
.br
	(b) .sp 2
.br
	(c) both
.ne 10
.L1
Briefly explain the following:
.br
	(a) .de
.br
	(b) .ds
.br
	(c) \\\\$n
.L1
Execution of  a macro is delayed until a _________ ___________ or a
______________ is encountered.
.L1
A character string "po" has been defined; write the command used to
display its text.
.L1
Write the command which causes a maximum of 40 characters to be placed
on each line.
.L1
Write 2 commands which can be used to prepend 5 spaces to output lines.
.L1
Write the necessary commands to define and execute a macro which
displays a title containing the current date and page number
at the top of each page.
.L1
Write a command which will display a slash each time a period is
encountered in the file.
.sp 2
Correct your test by the key located on the next page.  If
you miss more than 5 questions, please review this module before
continuing to module III.  Contact your instructor if you need
additional help.
.bp
.PH "Answers to module II test"
.sp
.L1 5 2 1
.I "Nroff"
is the command used to gain access to the nroff program.
.L1
The nroff program is used for
.I "formatting text."
.L1
The command:
.I "nroff -o1,10 junk"
will display the file, "junk", ending after page 10.
.L1
.L2
\&.bp 8 -- will begin a new page and will number the new
page 8.
.L2
\&.pn 8 -- will number the first page 8.
.L2
\&.po 8 -- will prepend 8 spaces to each output line.
.E2
.L1
.I "\&.pl 40"
is the command used to place a maximum of 40 lines on
each page.
.L1
.I "\&.nf,.br, and .sp"
will cause the "fill line mode" to be
ineffective.
.L1
.I "\&.ad c and .ce"
are used to center output lines. ".ad c" will center with line filling
and ".ce" will center without line filling.
.L1
.I "\&.ls 2"
will cause double spacing. ".sp 2" will cause triple spacing since
it causes 2 blank lines to be displayed.
.L1
.L2
\&.de -- defines a macro.
.L2
\&.ds -- defines a character string.
.L2
\\$n -- defines an argument.
.E2
.L1
Execution of a macro is delayed until a
.I "macro~reference"
or a
.I "trap"
is encountered.
.L1
.I "\\\&*(po"
will display the character string, "po."
.L1
.I "\&.ll 40"
will cause a maximum of 40 characters to be
placed on a line.
.L1
.I "\&.in 5 and .po 5"
will prepend 5 spaces to output lines.
.L1
\&.de xx
.br
\&.tl '\\n(mo \\n(dy \\n(yr''page%'
.br
\&..
.br
\&.wh 0 xx
.br
will define and execute a macro which displays a title containing
the current date and page number in upper case roman at the top
of a page.
.L1
.I \&.tr~./
will cause a slash to be displayed each time a period is
encountered.
.E1
