home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / PASTUT24.ZIP / PTUTRTXT.ZIP / INTRO.TXT < prev    next >
Encoding:
Text File  |  1989-12-01  |  13.2 KB  |  296 lines

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