	 Lesson 3: Reading, Writing, and Printing Files

      In this lesson, we introduce you to Perfect Writer's use of
computer "files".  Your computer's filing system is similar to
the one you or I use.  If you want to look at an old report, what
do you do?  You pull out the file from the filing drawer, and put
it on your desk.  To find a particular spot in the report, you
page through it on your desk.  You might change it or add
something to it, then put it back into the file drawer.

      The operations are similar on the computer system.  The
only differences are the ways in which the "file drawers",
"files", and "pages" work, and in the terms used.  In this sense,
you can think of the disk drive as the filing cabinet and each of
the flexible "floppy disks" as a removable filing drawer.  One of
the properties of these disks is that they are only useful
when put into the disk drive, which is not true of filing drawers
and cabinets!  On each of the disks, as in each of the drawers,
are many files.  You can see what files you have in a drawer
either by leafing through them, or by looking at the short label
on the front of the file drawer.  There is a label space on each
flexible disk which is similar to the one on the whole drawer,
but how can you find out the names on each of the files?  There
is a computer program to do this for you.  When you are not using 
Perfect Writer, and you have a disk drive prompt, just try typing 
"DIR" for Directory, and  it will list the names of the files.  
Most files have two names, like "THISFILE.MSS", that is, a file 
name, then a dot, and then an extension.  The first part (the 
filename) can't be longer than eight characters, and the second 
part (the extension) can be up to three characters long.  For 
Perfect Writer, the extension ".MSS" (standing for ManuScript 
Source) is always used for document files.  This is a lot more 
limited than what you can write on a file folder, so you can now 
understand why some computer files seem to have such cryptic names.

      What is the analogy of getting the file out and putting it
on your desk?  To Perfect Writer, this is called "reading" a
file.  Perfect Writer has an unusual way of manipulating it,
though.  Just as you would probably not mark up the originals of
a report in your file folder, Perfect Writer does not usually
change the contents of the file on the floppy disk.  You would
make a photocopy of your work, mark it up or change it, and then
perhaps retype it and replace what was originally in the file
folder.  Perfect Writer does something similar: it "reads in" a
copy of that file, and then lets you modify that copy.  

      There is a command in Perfect Writer to save the work that
you've been doing as the original again.  This is analogous to
putting your new work back into the file, and back into the file
drawer.  To Perfect Writer this is known as "writing" the file. 

      In Perfect Writer, the part which performs the function of
the working desk while we manipulate the file is the "buffer". 
Files are "read in" to the buffer, and they are "written out"
back to the computer filing system.  The computer terminal screen
is a sort of window into that buffer, and we can move the window
around with the control commands you have learned in previous
lessons.  

      Here are the commands:

	      C--X  C--F:      Find the file in the computer
                               filing system, and read it into the
	                       Perfect Writer buffer.
      
	      C--X  C--W:      Write the file out from the Perfect
			       Writer buffer back into the computer
	                       filing system.

      The C--X commands are a set of commands which are a little
harder to type, because we need to be certain we want to execute 
them.  Remember the "C--X C--C" command?  It has the possibility 
of letting you out of Perfect Writer without having saved the 
work you've been doing.  Therefore it's a little harder to type.  
The easiest way to remember what the C--X means is to imagine 
that these specialized commands are part of the "eXtended" 
command set.

      The "C--X C--F" command, in order to read a file, must know
which file you want to read.  When used, it will ask, in the echo
line (the last line on the screen), for the name of the file you
wish to read into Perfect Writer's buffer: 

      File to Find <CR>:

Similar things happen with the "C--X C--W" command.  In general,
we will want to write out the buffer back to the same file we
read it in from, but occasionally, we will want to save it in a
new file.  (This is particularly true of a form letter that we
modify slightly for a particular recipient and do not want to
change the original.)  After you type "C--X C--W", Perfect
Writer will ask:

      File to Write <CR>:

You can again type in the name of the file into which the text is
to be written, followed by a carriage-return.  

      Since writing files back out to the same place they were
read from is such a common operation, Perfect Writer allows you
to avoid typing the entire file name each time you give the C--X
C--W command.  Rather than typing out the file name, just type a
carriage-return.  Perfect Writer will write the buffer out to the
computer filing system under whatever name was last used in
either a C--X C--F or C--X C--W command.  How do you know where
it will go without always remembering the file name you last
used?  Perfect Writer displays that file name in the "mode line". 
It looks something like:

    Perfect Writer  1.03 (Fill) main  A:-NAME.ME -0%-

and the phrase "A:-NAME.ME" says what the default file name
will be if we do not specify it.  (You may have noticed the "B:"
alongside the file name.  This is due to the fact that computers,
like people, have many filing cabinets.  Just as you would tell
someone that a file is in the "right-hand" filing cabinet, you
must tell the computer in which disk drive to look for or store 
the file.  The computer disk drives you will be using are named 
"A", "B", etc.)


      Some files get quite large.  Computer files are no
exception.  Computer users just measure them in thousands of
characters rather than in inches of paper.  If you had a very
large file to look at, you would never fit each page of paper
side-by-side on your desk, so that you could see all of them at
any instant.  Instead, you would probably keep 5 or so pages
spread out on your desk, and keep the rest in stacks,
occasionally removing or adding a page on a stack.


      Similarly, many thousands of characters cannot all fit into
your computer at once.  Therefore, your buffers of text may not be
completely residing in memory at once.  Perfect Writer has a
special file on disk (not related to the other files we've been
talking about) which is similar to the stacks of paper you would
keep on your desk.  As you use each new page (thousand
characters) of the text buffer you are editing, Perfect Writer
will pull it out of the "stack of pages" by reading it from its
special "swap file".


      If you go back to old pages or add new text to pages, they
will generally be in memory, rather than on the stack in the page
file.  But, occasionally, the computer's memory will fill up, as
would your desk if you kept looking at more and more pages.  So,
occasionally, Perfect Writer must write some of its old pages
back to disk in order to make room for new ones.



      You will know this is happening by the click or buzz at the
disk drives.  There will also be a message printed at the lower
right of the screen" "Swapping..." which means that Perfect
Writer is exchanging a page on disk for a page in memory.  This
message will go away when the swap is complete.  This swapping is
part of the virtual memory architecture used by Perfect Writer to
allow you to edit a document that is larger than your computer's
memory. 



      Why do you need to know all this?  Well, occasionally you
may have to wait for this page swapping to happen.  Why?  The
computer stops listening to the terminal keyboard for a short
time when it swaps pages.  In particular, when you are just
beginning to work on a buffer of text which you read in via a
C--X C--F command, pieces of the buffer will be paged in as you
need them.  This means that C--V's will occasionally take a
little longer than usual and produce the "Swapping..." message. 
Once read in, though, the pages you use most (i.e., modify or go
back to) will remain, and "page waits" will be less frequent.

      If you stop using the keyboard for a little while, Perfect
Writer may spend a little time "cleaning up" while you are idle. 
It will swap out pages you have modified, so that any page
swapping which is done while you are actually doing work later
will occur a little faster.  Don't worry about this too much;
when you start typing on the keyboard again, the intermittent
house cleaning noises will go away.

PRINTING FILES

    After you have finished preparing a document and saving it
using the SAVE FILE Command, you are ready to print it.  To print
a document you will need to exit the editor (which you are in
now) and return to the Main Selection Menu.  The Main Selection
Menu will present you with several choices:

  --------------------------------------------------------
       E - Edit a file                <pw>
       F - Format a file              <pf>
       P - Print a formatted file     <pp>
  ---------------------------------------------------------

     You have already learned that selection  E  allows you to
create or edit a document.  The selection you want now is  F  to
format a file.  When you select this option the menu program asks
for the name of the file you wish to format or print.  At this
point you will simply supply the name of the file you wish to
print (be sure to include the disk location of the file; i.e.,
"b:filename" if the file is on drive B).  

The menu will then transfer you to the 'Format Selection Menu'
and present the following choices: 

  ---------------------------------------------------------
        C - Send the output to the console device 
        D - Format for a different device type
        P - Send the output to the printer device
        O - Name the output file differently 
        V - Make the top level environment Verbatim
        G - Start formatting now 
        X - Return to the top level of the menu 
  --------------------------------------------------------- 
Let's examine the various options.  The first choice 'C' prints
your document to the console.  This allows you to see what your
finished document will look like before printing it.

     'D' allows you to specify the printer you wish to use.  If
you want to use a printer besides the default simply select this
option and supply the printer name.  

     'P' allows you to print your file.  This is the quick print
option.  The limitation of the quick print option is that it does
not support boldface, underline or microspacing.  If you are not
using these print features, then this option will be all you
need. 
  
      'O' This option allows you to change the name of your
output file.  


      'V' allows you to print your file exactly as it appeared on
the screen (in terms of margins, tabs and spacing).  Perfect
Writer provides a powerful set of formatting commands that should
improve the ease and quality of your documents.  When you learn
these formatting commands and begin using them, you will not
select this option, but will use the default "TEXT" as the usual
format environment.  The text files on the lessons diskette can
be used with the document design lessons in your manual to learn
how to use the format commands.
 

      'G' instructs Perfect Writer to begin executing all of the
selections (if any) you have made.  If you are printing a
document with boldface or underline commands in it, then this may
be your only selection.  In this case, Perfect Writer will format
your document and prepare it for printing using the 'Print a
formatted file' option from the Main Selection Menu.

	If you have a simple document file, then you will usually
just select option 'P', 'V' and then 'G'.  Your document will
then be printed.   After your document is printed, Perfect Writer
will return you to the Main Selection Menu.



      Don't worry about trying out the commands you have learned
in this lesson.  In the next lesson, you will get a chance to try
out "C--X  C--R".  If you want, go to lesson4 by entering:

	C--X  C--R 

and answering "B:lesson4" when asked, 'File to Read <CR>:'.
on the lessons diskette can
be used with the document design lessons in you