home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / PAS_TUT.ZIP / INTRO.TXT < prev    next >
Encoding:
Text File  |  1991-02-04  |  13.4 KB  |  295 lines

  1.  
  2.  
  3.  
  4.                                                      INTRODUCTION
  5.  
  6. IF YOU KNOW NOTHING ABOUT PASCAL
  7. _________________________________________________________________
  8.  
  9. Assuming you know nothing at all about Pascal, and in fact, that
  10. you may know nothing about programming in general, we will begin
  11. to study Pascal.  If you are already somewhat familiar with
  12. programming and especially Pascal, you will probably want to skip
  13. very quickly through the first few chapters.  You should at least
  14. skim these chapters, and you should read the remainder of this
  15. introduction.
  16.  
  17. A few comments are in order to get us started in the right
  18. direction.  The sample programs included on the disks are designed
  19. to teach you the basics of Pascal and they do not include any
  20. clever or tricky code.  Nearly all of the programs are really quite
  21. dumb as far as being useful programs, but all will teach one or
  22. more principles of Pascal.  I have seen one tutorial that included
  23. a 12 page program as the first example.  In fact there were only
  24. 2 example programs in the entire tutorial, and it was impossible
  25. to glean the essentials of programming from that system.  For this
  26. reason, I will completely bypass any long programs until the very
  27. end of this tutorial.  In order to illustrate fundamental concepts
  28. used in Pascal programming, all programs will be very short and
  29. concise until we reach the last chapter.  
  30.  
  31.  
  32. LARGER PASCAL PROGRAMS
  33. _________________________________________________________________
  34.  
  35. Chapter 16 has some rather large programs to illustrate to you how
  36. to write a large program.  It would be a disservice to you to show
  37. you all of the constructs of Pascal and not show you how to put
  38. them together in a meaningful way to build a large program.  After
  39. completing all of the fundamentals of Pascal, it will then be very
  40. easy for you to use the tools learned to build as large a program
  41. as you desire or require for your next programming project.
  42.  
  43. Another problem I have noticed in example programs is the use of
  44. one word for all definitions.  For example, a sort program is
  45. stored in a file called SORT, the program is named Sort, and
  46. various parts of the program are referred to as Sort1, Sort2, etc. 
  47. This can be confusing since you have no idea if the program name
  48. must be the same as the filename, or if any of the other names were
  49. chosen to be the same because of some obscure rule not clearly
  50. documented.  For this reason, the example programs use completely
  51. arbitrary names whenever the choice of a name adds nothing to the
  52. readability or clarity of a program.  As an illustration of this,
  53. the first program is named Puppy_Dog.  This adds nothing to the
  54. understanding of the program but does illustrate that the program
  55. name means nothing to the Pascal compiler concerning what the
  56. program does.
  57.  
  58.                                                          Page I-1
  59.  
  60.                                                      Introduction
  61.  
  62. Due to the fundamental design of the Pascal language, certain words
  63. are "reserved" and can only be used for their defined purposes. 
  64. These are listed in your TURBO Pascal reference manual.  All of the
  65. sample programs in this tutorial are written with the reserved
  66. words in all lower-case letters, and the user variables in lower
  67. case with the first letter capitalized since this is becoming the
  68. accepted industry standard.  Don't worry about what reserved words
  69. are yet, they will be completely defined later.
  70.  
  71. In this tutorial, all reserved words, type names, variable names,
  72. and procedure and function names will be listed in boldface type
  73. within the text as an aid to the student.  Because it would add
  74. little and could possible be confusing, the simple predefined types
  75. will not be listed in boldface type.
  76.  
  77.  
  78. WHAT IS A COMPILER?
  79. _________________________________________________________________
  80.  
  81. There are two methods used to run any computer program that is
  82. written in a readable form of English.  The first method is to use
  83. an interpreter.  An interpreter is a program that looks at each
  84. line of the "English" program, decides what the "English" on that
  85. line means, and does what it says to do.  If one of the lines is
  86. executed repeatedly, it must be scanned and analyzed each time,
  87. greatly slowing down the solution of the problem at hand.  A
  88. compiler, on the other hand, is a program that looks at each
  89. statement one time and converts it into a code that the computer
  90. understands directly.  When the compiled program is actually run,
  91. the computer does not have to figure out what each statement means,
  92. it is already in a form that the computer can run directly,
  93. resulting in a much faster execution of the program.
  94.  
  95. This tutorial is written especially for Borland International's
  96. TURBO Pascal compilers version 5.0 through 6.0.  These are very
  97. high quality compilers that can do nearly anything you will ask
  98. them to do since they are so flexible.  The original intent of this
  99. tutorial was to write it in such a way that it would be completely
  100. generic and usable with any good Pascal compiler.  The programmers
  101. at Borland included a great many nonstandard aids for the Pascal
  102. language and resulted in a very good product that has dominated the
  103. market for microcomputers.  To completely omit all of the
  104. extensions would do those of you with the Borland compiler a real
  105. disservice, and to include the extensions would not allow other
  106. compilers to be used effectively with this tutorial.
  107.  
  108. The decision was made to use the Borland extensions and make the
  109. tutorial very difficult to use with other compilers.  If you have
  110. a need to use Pascal with some other compiler, TURBO Pascal is so
  111. inexpensive that it would be a wise decision to purchase a copy
  112. solely for the purpose of learning the Pascal programming language,
  113. then moving to a larger compiler on a minicomputer or a mainframe
  114. using the accumulated knowledge to very quickly learn the
  115.  
  116.  
  117.                                                          Page I-2
  118.  
  119.                                                      Introduction
  120.  
  121. extensions provided by that particular compiler.  At any rate, this
  122. tutorial will not teach you everything you will ever need to know
  123. about Pascal.  It will, however, teach you the fundamentals and the
  124. advanced features of Pascal, but of even more importance is the
  125. definition of Pascal terminology needed to progress on your own
  126. into more advanced topics of Pascal and programming in general. 
  127. You will find that experience will be your best teacher.
  128.  
  129.  
  130. WHICH VERSION OF TURBO PASCAL?
  131. _________________________________________________________________
  132.  
  133. Some of the example programs will not work with some of the earlier
  134. versions of TURBO Pascal.  This is primarily due to fact that
  135. object oriented programming capabilities were added to version 5.5,
  136. and improved on in version 6.0.  Most of the example programs will
  137. work with any version however.  It should be pointed out that each
  138. successive version of TURBO Pascal has been an improvement over the
  139. previous version since additional capabilities have been added, and
  140. each new one compiles a little faster and results in smaller but
  141. faster executable code than the previous version.  Any of the
  142. versions of TURBO Pascal can be used to learn to program in Pascal,
  143. so whichever version you have on hand will be adequate.  Later,
  144. when you become more versed in programming techniques, you may wish
  145. to upgrade to the absolute latest version.
  146.  
  147.  
  148. EARLY VERSIONS OF TURBO PASCAL
  149. _________________________________________________________________
  150.  
  151. Most of the files will compile properly with TURBO Pascal versions
  152. 2.0 through 4.0.  No warning will be given about which files will
  153. not compile with these versions since they have been superseded for
  154. so long.  If you are still using one of the earlier versions, it
  155. would you to purchase a newer version because of the flexibility. 
  156.  
  157.  
  158. WHAT ABOUT TURBO PASCAL VERSION 5.5 & 6.0?
  159. _________________________________________________________________
  160.  
  161. Chapters 14 and 15 of this tutorial are written especially for
  162. TURBO Pascal version 5.5 and 6.0 to discuss the use of object
  163. oriented programming and how to use the Borland extensions.  Since
  164. the topic of object oriented programming is a very large and
  165. diverse field of study and only a limited space is available to
  166. discuss it in this tutorial, these chapters will give you only a
  167. brief overview of what it is and how to use it.  You will find 13
  168. complete example programs to get you started in this new and very
  169. meaningful endeavor and this introduction should whet your appetite
  170. to continue your study in more depth.
  171.  
  172. If you are using an early version of TURBO Pascal without the
  173. object oriented extensions, it would pay you to upgrade to learn
  174. how to use this new programming method.  Object oriented
  175.  
  176.                                                          Page I-3
  177.  
  178.                                                      Introduction
  179.  
  180. programming has the potential to greatly improve the quality of
  181. your code and to reduce the debugging time required.
  182.  
  183.  
  184. PREPARATION FOR USE OF THIS TUTORIAL.
  185. _________________________________________________________________
  186.  
  187. Copy the example files into your TURBO Pascal working directory and
  188. you are ready to begin, provided of course that you have already
  189. learned how to start the TURBO system and how to edit a Pascal
  190. file.  Be sure you make a backup copy of the Pascal source disk so
  191. you cannot accidentally lose all information on the distribution
  192. disk.  TURBO Pascal version 5.x (5.0 or 5.5) users should read
  193. chapters 1 and 2 of the User's Guide, while version 6.0 users
  194. should read chapter 1 and quickly browse through chapters 7 and 8
  195. of the User's Guide.  You should be familiar with the use of the
  196. editor supplied with TURBO Pascal before beginning.
  197.  
  198. If you are not using TURBO Pascal, you will still be able to
  199. compile and execute many of these Pascal files, since most of the
  200. examples use standard Pascal syntax.  There will be some statements
  201. used which are unique to TURBO Pascal and will not work with your
  202. compiler.  This will be especially true when you come to the
  203. chapter on standard input and output since this is where most
  204. compilers differ.  Unfortunately, this is one of the most important
  205. aspects of any programming language, since it is required to get
  206. data into and out of the computer to do anything useful.  You will
  207. also find that chapter 13, covering the topic of units, is unique
  208. to TURBO Pascal and will not work with any Pascal compilers other
  209. than TURBO Pascal.
  210.  
  211.  
  212.  
  213. WHAT ABOUT THE PROGRAMMING EXERCISES?
  214. _________________________________________________________________
  215.  
  216. It is highly suggested that you do the programming exercises after
  217. you complete the study for each chapter.  They are carefully
  218. selected to test your understanding of the material covered in that
  219. chapter.  If you do not write, enter, debug, and run these
  220. programs, you will only be proficient at reading Pascal.  If you
  221. do the exercises completely, you will have a good start at being
  222. a Pascal program writer.
  223.  
  224. It should also be mentioned that this tutorial will not teach you
  225. everything you will ever need to know about Pascal.  You will
  226. continue to learn new techniques as long as you continue to write
  227. programs.  Experience is the best teacher here just as it is in any
  228. endeavor.  This tutorial will teach you enough about Pascal that
  229. you should feel very comfortable as you search through the
  230. reference manual for some topic.  You will also be able to read and
  231. understand any Pascal program you find in textbooks or magazines. 
  232. Although the primary goal of this tutorial is to teach you the
  233. syntax and use of Pascal, the most important byproduct is the
  234.  
  235.                                                          Page I-4
  236.  
  237.                                                      Introduction
  238.  
  239. knowledge of Pascal terminology you will gain.  This terminology
  240. will enable you to learn even more about Pascal and programming in
  241. general.
  242.  
  243.  
  244. THE ANSWERS DIRECTORY
  245. _________________________________________________________________
  246.  
  247. There is a directory on the distribution disk named ANSWERS which
  248. contains an answer to each of the programming exercises given at
  249. the end of the chapters.  You should attempt to do original work
  250. on each of the exercises before referring to these answers, in
  251. order to gain your own programming experience.  These answers are
  252. given for your information in case you are completely stuck on how
  253. to solve a particular problem.  These answers are not meant to be
  254. the only answer, since there are many ways to program anything, but
  255. they are meant to illustrate one way to solve the suggested
  256. programming problem.
  257.  
  258. The answers are all in executable files named in the format
  259. CHnn_m.PAS where nn is the chapter number, and m is the exercise
  260. number.  If there is more than one answer required, an A, B, or C
  261. is included following the exercise number.
  262.  
  263.  
  264. A SPECIAL NOTE FOR THE SHAREWARE VERSION
  265. _________________________________________________________________
  266.  
  267. It is impossible to include the graphics diagrams in chapter
  268. 12 in a pure ASCII text.  They are therefore omitted from this
  269. version of the tutorial.  If you need these diagrams, they can
  270. be purchased directly from Coronado Enterprises along with 
  271. your registration.  See the READ.ME file on either diskette
  272. for more information.
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.                                                          Page I-5
  295.