home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PASCTUT1.ZIP / INTRO.TXT < prev    next >
Encoding:
Text File  |  1986-07-14  |  7.1 KB  |  191 lines

  1.                 Introduction to the TURBO Pascal Tutorial
  2.  
  3.  
  4.             Assuming  you know nothing at all about Pascal,  and  in 
  5.         fact,  that  you  may  know  nothing  about  programming  in 
  6.         general,  we will begin to study Pascal.  If you are already 
  7.         somewhat  familiar  with programming and especially  Pascal, 
  8.         you  will  probably want to skip very  quickly  through  the 
  9.         first few chapters.   You should at least skim the first few 
  10.         chapters,   and  you  should  read  the  remainder  of  this 
  11.         introduction.
  12.  
  13.             A  few  comments are in order to get us started  in  the 
  14.         right direction.   The sample programs included on the disks 
  15.         are  designed to teach you the basics of Pascal and they  do 
  16.         not  include any clever or tricky code.   Nearly all of  the 
  17.         programs  are  really  quite  dumb as far  as  being  useful 
  18.         programs,  but  all  will teach one or  more  principles  of 
  19.         Pascal.   I  have seen one tutorial that included a 12  page 
  20.         program  as  the first example.   In fact there were only  2 
  21.         example programs in the entire tutorial.   I will completely 
  22.         bypass any long programs until the very end of this tutorial 
  23.         in order to illustrate concepts used in Pascal  programming.  
  24.         It  will then be very easy for you to use the tools  learned 
  25.         to build as large a program as you desire.
  26.  
  27.             Due  to  the fundamental design of the Pascal  language, 
  28.         certain words are "reserved" and can only be used for  their 
  29.         defined purposes.   These are listed on page 37 of the TURBO 
  30.         PASCAL  manual (version 3.0 will be used in all references).  
  31.         All  of  the sample programs are written with  the  reserved 
  32.         words  in  all capital letters,  and the user  variables  in 
  33.         lower case.   Don't worry about what reserved words are yet, 
  34.         they will be completely defined later.
  35.  
  36.             Another  problem I have noticed in example  programs  is 
  37.         the  use of one word for all definitions.   For  example,  a 
  38.         sort program is stored in a file called SORT, the program is 
  39.         named SORT, and various parts of the program are referred to 
  40.         as SORT1,  SORT2, etc.  This can be confusing since you have 
  41.         no  idea  if  the  program  name must be  the  same  as  the 
  42.         filename, or if any of the other names were chosen to be the 
  43.         same  because of some obscure rule not  clearly  documented.  
  44.         For  this  reason,   the  example  programs  use  completely 
  45.         arbitrary  names whenever the choice of a name adds  nothing 
  46.         to  the  readability  or  clarity  of  a  program.    As  an 
  47.         illustration of this,  the first program is named puppy_dog.  
  48.         This  adds  nothing to the understanding of the program  but 
  49.         does  illustrate that the program name means nothing to  the 
  50.         Pascal compiler concerning what the program does.
  51.  
  52.             What is a compiler?   There are two primary methods used 
  53.         in  running  any  computer  program that  is  written  in  a 
  54.  
  55.  
  56.  
  57.                                   Page 1
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                 Introduction to the TURBO Pascal Tutorial
  68.  
  69.  
  70.         readable   form  of  English.    The  first  method  is   an 
  71.         interpreter.  An interpreter is a program that looks at each 
  72.         line of the "English" program, decides what the "English" on 
  73.         that line means, and does what it says to do.  If one of the 
  74.         lines  is  executed  repeatedly,  it  must  be  scanned  and 
  75.         analyzed each time, greatly slowing down the solution of the 
  76.         problem  at  hand.   A compiler,  on the other  hand,  is  a 
  77.         program  that looks at each statement one time and  converts 
  78.         it into a code that the computer understands directly.  When 
  79.         the compiled program is actually run,  the computer does not 
  80.         have to figure out what each statement means,  it is already 
  81.         in a form that the computer can run directly,  hence a  much 
  82.         faster execution of the program.
  83.  
  84.                    PREPARATION FOR USE OF THIS TUTORIAL.
  85.  
  86.              Copy the example files onto your TURBO working disk and 
  87.         you  are  ready to begin,  provided of course that you  have 
  88.         already  learned  how to start the TURBO system and  how  to 
  89.         edit a Pascal file.   Be sure you make a backup copy of  the 
  90.         Pascal  tutorial disks so you cannot accidentally  lose  all 
  91.         information  on  the distribution disks.   You  should  read 
  92.         Chapter  1 of the TURBO Pascal reference manual to be  ready 
  93.         to  use this tutorial.   You should be familiar with use  of 
  94.         the editor supplied with TURBO Pascal before beginning.
  95.  
  96.             If  you are not using TURBO Pascal,  you will  still  be 
  97.         able  to  compile  and execute most of these  Pascal  files, 
  98.         since  most  of the examples use "standard"  Pascal.   There 
  99.         will  be  some  statements used which are  unique  to  TURBO 
  100.         Pascal and will probably not work with your compiler.   This 
  101.         will  be  especially true when you come to  the  chapter  on 
  102.         standard input and output since this is where most compilers 
  103.         differ.   Unfortunately,  this  is one of the most important 
  104.         aspects of any programming language, since it is required to 
  105.         get data into and out of the computer to do anything useful.
  106.  
  107.             It  is  highly  suggested that you  do  the  programming 
  108.         exercises  after  you complete the study for  each  chapter.  
  109.         They  are carefully selected to test your  understanding  of 
  110.         the material covered in each chapter.   If you do not write, 
  111.         enter,  debug,  and  run  these programs,  you will only  be 
  112.         proficient  at  reading Pascal.   If you  do  the  exercises 
  113.         completely,  you  will  have a good start at being a  Pascal 
  114.         program writer.
  115.  
  116.             It should also be mentioned that this tutorial will  not 
  117.         teach  you  everything  you  will ever need  to  know  about 
  118.         Pascal.   You will continue to learn new techniques as  long 
  119.         as  you continue to write programs.   Experience is the best 
  120.  
  121.  
  122.  
  123.                                   Page 2
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                 Introduction to the TURBO Pascal Tutorial
  134.  
  135.  
  136.         teacher here just as it is in any endeavor.   This  tutorial 
  137.         will  teach you enough about Pascal that you will feel  very 
  138.         comfortable  as you search through the reference manual  for 
  139.         some  topic.   You will also be able to read and  understand 
  140.         any Pascal program you find in textbooks or magazines.
  141.  
  142.             When you are ready, I will meet you in Chapter 1.
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.                                   Page 3
  190.  
  191.