home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug174.arc / FILECARD.LBR / MENU.PYS / MENU.PYS
Text File  |  1979-12-31  |  4KB  |  152 lines

  1. Program MENU;
  2. {This menu is written for the File Card Database.}
  3.  
  4. Var
  5.    Disk:       File;
  6.    Inkey:      Char;
  7.    A, B, X, Y: Integer;
  8.    Line:       String[80];
  9.    Flag:       Boolean;
  10.  
  11. Procedure IOError;
  12. Var
  13.    Num:   Integer;
  14.    IOErr: Boolean;
  15.    Key:   Char;
  16.  
  17. Begin
  18.    Num := 0;
  19.    IOErr := false;
  20.    Num := IOresult;
  21.    IOErr := (Num <> 0);
  22.    If IOErr then
  23.    Begin
  24.       Write(chr(7));
  25.       Clrscr;
  26.       Gotoxy(20,12);
  27.       Case Num of
  28.          $01:  Write('File does not exist');
  29.          $02:  Write('File not open for input');
  30.          $03:  Write('File not open for output');
  31.          $04:  Write('File not open');
  32.          $05:  Write('Can''t read from this file');
  33.          $06:  Write('Can''t write to this file');
  34.          $10:  Write('Error in numeric format');
  35.          $20:  Write('Operation not allowed on a logical device');
  36.          $21:  Write('Not allowed in the direct mode');
  37.          $22:  Write('Assign to standard files not allowed');
  38.          $90:  Write('Record length mismatch');
  39.          $91:  Write('Seek beyond end of file');
  40.          $99:  Write('Unexpected end of file');
  41.          $F0:  Write('Disk write error');
  42.          $F1:  Write('Directory is full');
  43.          $F2:  Write('File size overflow');
  44.          $FF:  Write('File dissappeared!');
  45.          Else  Write('Unknown I/O Error: ',Num:3);
  46.       End;
  47.       Gotoxy(20,14);
  48.       Write('Type any key to continue... ');
  49.       Read(Kbd,Key);
  50.       Assign(Disk,'MENU.COM');
  51.       Execute(Disk);
  52.    End;
  53. End;
  54.  
  55. Procedure CenterText;
  56. Begin
  57.    A := length(Line);
  58.    B := 80 - A;
  59.    X := B div 2;
  60.    Gotoxy(X,Y);
  61.    Write(Line);
  62. End;
  63.  
  64. Procedure DrawMenu;
  65. Begin
  66.    Clrscr;
  67.    Y := 2; Line := ('FILE CARD DATABASE'); CenterText;
  68.    Y := 4; Line := ('(c) 1984 by'); CenterText;
  69.    Y := 6; Line := ('Thomas R. Mierau'); CenterText;
  70.    Y := 8; Line := ('( Compiled with Turbo Pascal for the Microbee )'); CenterText;
  71.    Writeln;
  72.    For A := 1 to 80 do
  73.    Begin
  74.       Write('-');
  75.    End;
  76.    Y := 12; Line := ('<A>  Create a new database'); CenterText;
  77.    Y := 14; Gotoxy(X,Y); Write('<B>  Add records to database');
  78.    Y := 16; Gotoxy(X,Y); Write('<C>  Access existing records');
  79.    Y := 18; Gotoxy(X,Y); Write('<D>  Display key words');
  80.    Y := 20; Gotoxy(X,Y); Write('<ESC>  Quit');
  81.    Gotoxy(60,22); Write('Please select: ');
  82. End;
  83.  
  84. Procedure Choice;
  85. Begin
  86.    Flag := false;
  87.    Repeat
  88.       Gotoxy(75,22);
  89.       Read(Kbd,Inkey);
  90.       Inkey := upcase(Inkey);
  91.  
  92.       If Inkey = chr(27) then Flag := true;
  93.  
  94.       If Inkey = 'A' then
  95.       Begin
  96.          Clrscr;
  97.          Writeln('WARNING: This subprogram erases all existing data from the database.');
  98.          Writeln('use only if you wish to start a new database.');
  99.          Writeln;
  100.          Writeln;
  101.          Write('Type "*" to continue...any other key to abort: ');
  102.          Read(Kbd,Inkey);
  103.          If Inkey = '*' then
  104.          Begin
  105.             {$I-}
  106.             Assign(Disk,'NEWFILE.CHN');
  107.             Chain(Disk);
  108.             IOError;
  109.             {$I+}
  110.          End;
  111.          Inkey := chr(0);
  112.          DrawMenu;
  113.       End;
  114.  
  115.       If Inkey = 'B' then
  116.       Begin
  117.          Clrscr;
  118.          {$I-}
  119.          Assign(Disk,'MAINBODY.CHN');
  120.          Chain(Disk);
  121.          IOError;
  122.          {$I+}
  123.       End;
  124.  
  125.       If Inkey = 'C' then
  126.       Begin
  127.          Clrscr;
  128.          {$I-}
  129.          Assign(Disk,'RETRIEVE.CHN');
  130.          Chain(Disk);
  131.          IOError;
  132.          {$I+}
  133.       End;
  134.  
  135.       If Inkey = 'D' then
  136.       Begin
  137.          Clrscr;
  138.          {$I-}
  139.          Assign(Disk,'SORTFILE.CHN');
  140.          Chain(Disk);
  141.          IOError;
  142.          {$I+}
  143.       End;
  144.  
  145.    Until Flag;
  146.    Clrscr;
  147. End;
  148.  
  149. Begin
  150.    Drawmenu;
  151.    Choice;
  152. End.