home *** CD-ROM | disk | FTP | other *** search
- Introduction to the TURBO Pascal Tutorial
-
-
- Assuming you know nothing at all about Pascal, and in
-
- fact, that you may know nothing about programming in
-
- general, we will begin to study Pascal. If you are already
-
- somewhat familiar with programming and especially Pascal,
-
- you will probably want to skip very quickly through the
-
- first few chapters. You should at least skim the first few
-
- chapters, and you should read the remainder of this
-
- introduction.
-
- A few comments are in order to get us started in the
-
- right direction. The sample programs included on the disks
-
- are designed to teach you the basics of Pascal and they do
-
- not include any clever or tricky code. Nearly all of the
-
- programs are really quite dumb as far as being useful
-
- programs, but all will teach one or more principles of
-
- Pascal. I have seen one tutorial that included a 12 page
-
- program as the first example. In fact there were only 2
-
- example programs in the entire tutorial. I will completely
-
- bypass any long programs until the very end of this tutorial
-
- in order to illustrate concepts used in Pascal programming.
-
- It will then be very easy for you to use the tools learned
-
- to build as large a program as you desire.
-
- Due to the fundamental design of the Pascal language,
-
- certain words are "reserved" and can only be used for their
-
- defined purposes. These are listed on page 37 of the TURBO
-
- PASCAL manual (version 3.0 will be used in all references).
-
- All of the sample programs are written with the reserved
-
- words in all capital letters, and the user variables in
-
- lower case. Don't worry about what reserved words are yet,
-
- they will be completely defined later.
-
- Another problem I have noticed in example programs is
-
- the use of one word for all definitions. For example, a
-
- sort program is stored in a file called SORT, the program is
-
- named SORT, and various parts of the program are referred to
-
- as SORT1, SORT2, etc. This can be confusing since you have
-
- no idea if the program name must be the same as the
-
- filename, or if any of the other names were chosen to be the
-
- same because of some obscure rule not clearly documented.
-
- For this reason, the example programs use completely
-
- arbitrary names whenever the choice of a name adds nothing
-
- to the readability or clarity of a program. As an
-
- illustration of this, the first program is named puppy_dog.
-
- This adds nothing to the understanding of the program but
-
- does illustrate that the program name means nothing to the
-
- Pascal compiler concerning what the program does.
-
- What is a compiler? There are two primary methods used
-
- in running any computer program that is written in a
-
-
-
-
-
- Page 1
-
-
-
-
-
-
-
-
-
- Introduction to the TURBO Pascal Tutorial
-
-
- readable form of English. The first method is an
-
- interpreter. An interpreter is a program that looks at each
-
- line of the "English" program, decides what the "English" on
-
- that line means, and does what it says to do. If one of the
-
- lines is executed repeatedly, it must be scanned and
-
- analyzed each time, greatly slowing down the solution of the
-
- problem at hand. A compiler, on the other hand, is a
-
- program that looks at each statement one time and converts
-
- it into a code that the computer understands directly. When
-
- the compiled program is actually run, the computer does not
-
- have to figure out what each statement means, it is already
-
- in a form that the computer can run directly, hence a much
-
- faster execution of the program.
-
- PREPARATION FOR USE OF THIS TUTORIAL.
-
- Copy the example files onto your TURBO working disk and
-
- you are ready to begin, provided of course that you have
-
- already learned how to start the TURBO system and how to
-
- edit a Pascal file. Be sure you make a backup copy of the
-
- Pascal tutorial disks so you cannot accidentally lose all
-
- information on the distribution disks. You should read
-
- Chapter 1 of the TURBO Pascal reference manual to be ready
-
- to use this tutorial. You should be familiar with use of
-
- the editor supplied with TURBO Pascal before beginning.
-
- If you are not using TURBO Pascal, you will still be
-
- able to compile and execute most of these Pascal files,
-
- since most of the examples use "standard" Pascal. There
-
- will be some statements used which are unique to TURBO
-
- Pascal and will probably not work with your compiler. This
-
- will be especially true when you come to the chapter on
-
- standard input and output since this is where most compilers
-
- differ. Unfortunately, this is one of the most important
-
- aspects of any programming language, since it is required to
-
- get data into and out of the computer to do anything useful.
-
- It is highly suggested that you do the programming
-
- exercises after you complete the study for each chapter.
-
- They are carefully selected to test your understanding of
-
- the material covered in each chapter. If you do not write,
-
- enter, debug, and run these programs, you will only be
-
- proficient at reading Pascal. If you do the exercises
-
- completely, you will have a good start at being a Pascal
-
- program writer.
-
- It should also be mentioned that this tutorial will not
-
- teach you everything you will ever need to know about
-
- Pascal. You will continue to learn new techniques as long
-
- as you continue to write programs. Experience is the best
-
-
-
-
-
- Page 2
-
-
-
-
-
-
-
-
-
- Introduction to the TURBO Pascal Tutorial
-
-
- teacher here just as it is in any endeavor. This tutorial
-
- will teach you enough about Pascal that you will feel very
-
- comfortable as you search through the reference manual for
-
- some topic. You will also be able to read and understand
-
- any Pascal program you find in textbooks or magazines.
-
- When you are ready, I will meet you in Chapter 1.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 3
-