program PreisListe;
(*$A+,C-,R-,V-*)

(****************************************************************)
(*                                                              *)
(*                    PreisListe Version 1.00                   *)
(*                                                              *)
(*                     Mario Bez   09.06.1986                   *)
(*                                                              *)
(****************************************************************)

label Stop, First;

const
  CustRegSize     =  100;           (*  customer record Size *)

(*  TURBO-access constants *)
  MaxDataRecSize  =  CustRegSize;   (*  max record Size *)
  MaxKeyLen       =  20;            (*  max key Size *)
  PageSize        =  16;            (*  page Size *)
  Order           =  8;             (*  half page Size *)
  PageStackSize   =  5;             (*  page buffer Size *)
  MaxHeight       =  5;             (*  max B-tree height *)

var
  NoOfRecs      : Integer;

(*$I ACCESS.BOX*)
(*$I GETKEY.BOX*)
(*$I ADDKEY.BOX*)
(*$I DELKEY.BOX*)

type
  Str5    =  string[5];
  Str8    =  string[8];
  Str10   =  string[10];
  Str15   =  string[15];
  Str20   =  string[20];
  Str25   =  string[25];
  Str80   =  string[80];
  AnyStr  =  string[255];
  CharSet =  set of Char;

  CustRec = record
              Nummer     : Integer;
              DeviceName : Str20;         (*  Bauteilname  *)
              Preis      : Str8;          (*  Bauteilpreis *)
              Remarks1   : Str20;         (*  remarks 1 *)
              Remarks2   : Str20;         (*  remarks 2 *)
              Remarks3   : Str20          (*  ramarks 3 *)
            end;

var

(*  global variables *)
  DatF          : DataFile;
  IFile         : IndexFile;
  Ch            : Char;

{$I PREIS.INC}

(*  Main program *)

begin
  ClrScr ;
  Writeln(ConstStr('-',79));
  Writeln('Preis-Liste fuer Fa. City Elektronik');
  Writeln(ConstStr('-',79));
  GotoXY(1,22); Writeln(ConstStr('-',79));
  Writeln;
  Write(ConstStr('-',79)); GotoXY(1,4);
  InitIndex;
  OpenFile(DatF,'PREIS.DAT',CustRegSize);
  if OK then
    OpenIndex(IFile,'PREIS.IDX',15,0);
  if not OK then
  begin
    Select('Data files missing. Create new files (Y/N)',
                                              ['Y','N'], Ch);
    if Ch = 'Y' then
    begin
      MakeFile(DatF,'PREIS.DAT',CustRegSize);
      MakeIndex(IFile,'PREIS.IDX',25,1);
      goto First;
    end
    else goto Stop;
  end;
  GotoXY(60,2); Write(UsedRecs(DatF):5,' Eintraege');
  repeat
    Select('Waehle : U)pdate, L)ist, Q)uit', ['U','L','Q'], Ch);
    case Ch of
      'U' : Update;
      'L' : List;
    end;
    if Ch <> 'Q' then ClearFrame;
  until UpCase(Ch) = 'Q';
First :CloseFile(DatF);
  CloseIndex(IFile) ;
Stop :
  ClrScr;
end.
