home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / SPE.ZIP / PAS-EXAM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-06-14  |  2.8 KB  |  115 lines

  1. { PASCAL Program                       : pas-exam.spe
  2.   Date written                         : 3-3-86
  3.   Author                               : Ortolf
  4.   Structogram  saved on disk           : Spe110
  5.   Pascalsource saved on disk           : Pas52
  6.  
  7.  *                                                         main program
  8. }
  9.  program pasbsp1 (input, output);
  10. label 0909, 0918; 
  11.  const
  12.  t1 = 'Program Name: pas-exam.spe.';
  13.  t2 = 'Create file (1), display file (2)? ';
  14.  var
  15.  zchen : char;
  16. {
  17.  *                                                   subroutine
  18. }
  19.  procedure zweite;
  20. label 0484; 
  21.  const
  22.  t3 = 'Display another record (y/n)? ';
  23.  var
  24.  eins  : string (80);
  25.  zchen : char;
  26.  ein   : text;
  27.  a     : integer;
  28.   begin
  29.   assign (ein, 'pasbsp1.dat');
  30.   reset  (ein);
  31.   a := 1;                                  { initiate condition }
  32. {                                            conditioned loop      
  33.                                              while a = 1 loop }
  34.   while a = 1 do
  35. begin
  36. {                                         reading sucessful }
  37.   if (eof(ein))
  38.  then begin
  39. {      EOF } 
  40.  goto 0484
  41. end else begin
  42.   readln  (ein, eins);    { read record }
  43.   writeln (eins);         { display record }
  44.   writeln (t3);     
  45.   readln (zchen);
  46. {                           another record? } 
  47.   if (zchen = 'y')
  48.  then begin
  49. {                  yes } 
  50. end else begin
  51. {                    no   } 
  52.   a := 0;
  53.  end
  54.  end
  55.  end;
  56. 0484:
  57.   close (ein)
  58.   end;
  59. {
  60.  *                                                   subroutine
  61. }
  62.  procedure pasbsp;
  63. label 0810; 
  64.  const
  65.  t3 = 'How many record are to be written? ';
  66.  var
  67.  auss   : string (80);
  68.  zaehl  : integer;
  69.  anzahl : integer;
  70.  aus    : text;
  71.   begin
  72. {                                            case 1 
  73.                                              create file } 
  74.   assign  (aus, 'pasbsp1.dat');
  75.   rewrite (aus);
  76.   writeln (t3);                            { input number of records } 
  77.   readln  (anzahl);
  78.   for zaehl := 1 to anzahl do
  79. {                                            indexed loop   }
  80. begin
  81.   readln  (auss);                       { input record   }
  82.   writeln (auss);                       { display record }
  83.   writeln (aus, auss);                  { write record   }
  84.  end;
  85. 0810:
  86.   close (aus);
  87.   end;
  88.  begin
  89.  writeln (t1);
  90. {                                                  an unconditioned loop is 
  91.                                                    following }
  92. 0909:
  93. begin
  94.   writeln (t2);
  95.   readln (zchen);
  96. {                                               case }
  97.    if (zchen =      '1')
  98.  then begin
  99. {          case 1          } 
  100.   pasbsp { create file     }
  101. end else 
  102.    if (zchen =      '2')
  103.  then begin
  104. {          case 2        } 
  105.   zweite { display file  }
  106. end else begin
  107. {      else-case
  108.        end       } 
  109.  goto 0918
  110.  end
  111.  end;
  112.  goto 0909;
  113. 0918:
  114.  end.
  115.