The Pascal environment helps keep these two types of computer information separate while at the same time making it easy to set up and use the computer's memory in the process of solving a problem. One of the ways it does this is to make available to the user two distinctly different tools: an editor and a compiler. The Turbo editor allows you to type in your program on the computer keyboard. It organizes the program for you and allows you to store it on the diskette for later use or revision. The editor lets you piece together portions of different programs (= "cut and paste"). The Pascal language itself forces you to carefully define the instructions in your program and the kind of data you will be processing. This will become very clear as we progress over the next few weeks. The compiler is a special tool which takes the program file you constructed using the editor and makes a (temporary) translation of it into the native machine code of the CPU of your computer. In the process, the compiler alerts you to any errors you have made (using memory locations which have not been defined as to name and kind, missing punctuation, or misuse of the Pascal language, a so-called syntax error). In Turbo the compiler is a "single pass" compiler, so errors are reported in sequence, not all at once. When the compiler has alerted you to an error, the Turbo environment allows you to correct it and then proceed as before. If all goes well, your program will compile correctly. The Turbo environment will then allow you to "run" the program, whereby you can check to see if the output results are what you expected (sometimes, this is not at all obvious!). If the output results are not satisfactory, you then return to the editor to make further changes, recompile the updated code, check the output, either returning for more refinements or accepting the output as correct.
First, you must purchase a number of 3.5" HD diskettes (four or so should be sufficient). Go to the computer lab in McGraw or Anderson Library and format the diskettes (follow the menu system, and make sure that you use your last name when prompted for a label during the format process). The Disk Operating System (DOS) of all PCs stores information on a diskette in files. To the computer, a file is an organized collection of data. The computer knows where to find a file on a diskette by consulting the directory of the diskette which lists all the important information about each file in a special area on the diskette. Each file is named and the file's name is stored in the directory. When you use Turbo Pascal, you must, therefore, name each program file you construct. The name of a file in DOS has two parts: an eight character filename (8 characters maximum) and a three character filetype; these two segments of a file name are separated by a period (called "dot"). The filetype of Pascal program files is always PAS. Typical program file names you will deal with in this course are:
PROG_01.PAS (a Pascal program file)
TEST.DAT (an input data file, used by a program to obtain output)
RESULTS.OUT (an output text file, usually created by a program)
Use only alphanumeric characters in your file names (A, B, ..., Z,
0, 1, 2, ..., 9); upper and lower case letters in file names are
the same as far as DOS is concerned. The operating system keeps
track of the secondary storage device you are using (called the
default drive). In the Labs, this should always be a diskette
drive called A: (there may be some special instances when it will
be called B:). Notice that the colon (:) is a required part of
this designation. When the default drive is drive A: and your
diskette is in that drive, all your Pascal programs will be saved
(or retrieved) from your storage diskette. To make a backup copy
of your diskette, find a PC with two high density 3«" diskette
drives. From the file menu, exit to DOS. Put the diskette you
wish to copy in drive A: and a blank diskette in drive B: and use
the command DISKCOPY A: B: (this will copy everything on drive A:
to drive B:). This is the easy way to copy entire diskettes, but
there is an also an easy way to copy just a single file while you
are in the Turbo Editor. We will see how that works during in-
class demos. Remember, YOU are responsible for making adequate
backup copies of all your programs! Do NOT assume that lightening
always strikes the "other guy."