home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / modula2 / mod2txt.zip / CHAP9.TXT < prev    next >
Text File  |  1987-03-25  |  4KB  |  124 lines

  1.                         Chapter 9 - Example programs
  2.  
  3.  
  4.              The  programs included in this chapter are intended  to
  5.         be  illustrations to you in how to write a complete program.
  6.         The  programs  are meant to be useful to you  either  as  an
  7.         example  of how to do some operation or as utility  programs
  8.         for your general use.
  9.  
  10.                         TIMEDATE - Get Time and Date
  11.  
  12.              This  program calls one of the DOS functions to get the
  13.         current time and date.   They are input as variables and can
  14.         be  printed  or displayed in any format  you  desire.   Your
  15.         particular compiler may use a different format because there
  16.         is no standard in Modula-2.  This is one of those areas that
  17.         will  probably deviate from compiler to  compiler.   If  you
  18.         study  your documentation that came with your compiler,  you
  19.         will  find many other calls of this  type  described.   This
  20.         program  is  meant to be an illustration of how to use  this
  21.         particular call.
  22.  
  23.                           AREAS - Calculate Areas
  24.  
  25.              This program is intended to be an illustration for  you
  26.         of  how to build up a larger program than any other that  we
  27.         have  examined  up  to this point.   Notice  that  the  main
  28.         program  is simply one CASE statement that calls all of  the
  29.         other  procedures.   It would be very simple to include  the
  30.         code  from  each procedure right in the CASE  statement  and
  31.         have no procedure calls,  but it would make the program very
  32.         difficult to understand.  The way this example is coded, the
  33.         code  is very easy to understand.   After you understand the
  34.         main  program,  it  is a very simple matter  to  visit  each
  35.         procedure to see exactly what they do.
  36.  
  37.              Notice  how the menu works in this program.   It  reads
  38.         one  keystroke  and  responds immediately making it  a  very
  39.         simple program to use.
  40.  
  41.                             PC - Printer Control
  42.  
  43.              This  is  a  very useful program that you  can  use  to
  44.         control  your  printer.   It is specifically set up  for  an
  45.         Epson  RX-80,  but you can modify the control characters  to
  46.         set up your printer to whatever mode you desire.  To use the
  47.         program,  you  call the program and supply a  single  letter
  48.         according  to the displayed menu,  and the program will send
  49.         the  character  or characters to the printer to  select  the
  50.         enhanced,  compressed, or whatever mode you desire.  If your
  51.         printer is located physically remote from you,  you can  use
  52.         this  program to send a formfeed to the printer by selecting
  53.         the F option.   If you have some longer control sequences to
  54.         send, you may want to store the values in a string and use a
  55.  
  56.  
  57.                                    Page 58
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                         Chapter 9 - Example programs
  68.  
  69.  
  70.         loop to output the data until you come to an 0C character.
  71.  
  72.                           LIST - List Program File
  73.  
  74.              If you ran the batch file named LISTALL as suggested at
  75.         the  beginning  of  this tutorial to print out  all  of  the
  76.         source files, you have already used this program.  It is the
  77.         program that will list any ASCII file,  adding line numbers,
  78.         page numbers,  and the date and time, on the printer.  It is
  79.         specifically designed to be a program listing utility.   The
  80.         operation is very simple,  and you should have no trouble in
  81.         understanding this program or what it does.
  82.  
  83.              Additional  programs  will be given at the end of  Part
  84.         III for your information.  You will no doubt find additional
  85.         example  programs  in various books and periodicals  and  it
  86.         would  be to your advantage to to spend some  time  studying
  87.         them as illustrations of both good and bad practices.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.                                    Page 59
  124.