OVERLAY PROCEDURE DoEntry;
  VAR I,N,RecNum:Integer;
      SkipDup:Boolean;
  PROCEDURE AddRecord;
    Begin
      With FileRec do begin
        Status:=0;
        FileName:=Entry[N].EName+'.'+Entry[N].EExt;
        FileTime:=Entry[N].ETime;
        FileDate:=Entry[N].EDate;
        For I := 1 to 4 do FileSize[I]:=Entry[N].ESize[I];
        Floppy:=False;
        If SourceDirectory[1] in ['A','B'] then Floppy:=True;
        VolPath:=SourceDirectory;
        If Floppy then VolPath:=OldVolumeName;
      End;
      FKey:=Entry[N].EName+Entry[N].EExt;
      FKey:=FKey+ConstStr(' ',13-Length(FKey));
      If FileRec.StandAlone then FKey:=FKey+'1' Else FKey:=FKey+'0';
      AddRec(CFile,RecNum,FileRec);
      If OK then begin
        AddKey(CIndex,RecNum,FKey);
        AddKeywords;
      End;
      If NOT OK then begin
        DeleteRec(CFile,RecNum);
        GotoXY(1,24);ClrEol;
        Beep;
        Write('Error writing Record');
      End;
    End; { procedure AddRecord }

  Begin
    ShowScreen;
    FillChar(FileRec,SizeOf(FileRec),0);
    GotoXY(1,23);
    Write('Use Cursor UP, DOWN, HOME, END, PGUP, and PGDN, then');
    GotoXY(1,24);
    Write('press Return to select file from list.  Press ESC to quit. -->');
    GotoXY(1,25);
    Write('Press <F1> to enter ALL files   <S> to SORT into alpha order');
    SaveScreen;
    DrawBox(65,79,1,25);
    BigWindow(66,2,78,24);
    If MonitorType = 7 then begin
      HideCursor;
      For I:=1 to 23 do begin
        GotoXY(1,I);
        Write(ConstStr(' ',13));
      End;
      RestoreCursor;
      GotoXY(1,1);
    End Else ClrScr;
    LowVideo;
    UpdateArray;
    NormVideo;
    N:=SelectFile;
    BigWindow(1,1,80,25);
    RestoreScreen;
    GotoXY(1,23);ClrEol;
    GotoXY(1,24);ClrEol;
    NormVideo;
    If N=0 then Exit;
    If N=-1 then begin
      For I:=23 to 25 do begin
        GotoXY(1,I);
        ClrEol;
      End;
      GotoXY(1,24);
      Write('Enter ALL ',EntryNum,' files into database... Continue?  Y/N');
      Beep;
      If YES then begin
        GotoXY(1,24);ClrEol;
        Write('Ignore duplicate file names?  Y/N');
        Beep;
        SkipDup:=False;
        If YES then SkipDup:=True;
        OpenFiles;
        For N:=1 to EntryNum do begin
          ShowEntry(N);
          If (Entry[N].EStatus=1) and SkipDup then begin
            GotoXY(1,24);ClrEol;
            Write('Ignoring duplicate filename:  ',Entry[N].EName,'.',Entry[N].EExt);
            Boop;
          End Else begin
            FillChar(FTemp,SizeOf(FTemp),0);
            If Length(FTemp.ParentName)<12 then FTemp.ParentName:='        .   ';
            FTemp.StandAlone:=True;
            FileRec:=FTemp;
            AddRecord;
          End;
        End;
        CloseFiles;
      End;
      Exit;
    End;
    If Entry[N].EStatus=1 then begin
      ShowDuplicate(N);
      If Ch='Q' then Exit;
      ShowScreen;
    End;
    ShowEntry(N);
    FillChar(FTemp,SizeOf(FTemp),0);
    OpenFiles;
    EnterData;
    FileRec:=FTemp;
    Write('ADD the above entry to the database? Y/N ');
    If YES then AddRecord;
    CloseFiles;
    GotoXY(1,24);ClrEol;
    Beep;
    Write('Another entry from this disk/directory? Y/N ');
    If YES then DoEntry;
  End; { procedure DoEntry }

OVERLAY PROCEDURE BrowseEdit;
  VAR S,S1,S2,SKey,FKey:AnyStr;
      RecNum:Integer;
      Done,Printed,FullMatch,Matched,KeyCat:Boolean;
      I,J,K,MatchCount:Integer;

  PROCEDURE EnterSearch;
    Begin
      SaveScreen;
      DrawBox(10,70,17,21);
      BigWindow(11,18,69,20);
      If MonitorType = 7 then begin
        HideCursor;
        For I:=1 to 3 do begin
          GotoXY(1,I);
          Write(ConstStr(' ',59));
        End;
        RestoreCursor;
      End Else ClrScr;
      LowVideo;
      If KeySearch then begin
        GotoXY(5,2);
        Write(' Keyword to Search For:');
        S1:='';
        InputStr(S1,24,30,2,Af,[#13],Ch);
        For I:= 1 to Length(S1) do S1[I]:=Upcase(S1[I]);
        HideCursor;
        If Pos(' ',S1)>0 then begin
          Boop;
          GotoXY(2,1); Write('"',S1,'" truncated to "');
          S1[0]:=Chr(Pos(' ',S1)-1);
          Write(S1,'"');
        End;
        GotoXY(2,2); ClrEol;
        Write('Display:   <E> Exact matches   <P> Partial matches');
        Repeat
          Read(Kbd,Ch);
          Ch:=Upcase(Ch);
          If NOT (Ch in ['E','P']) then Boop;
        Until Ch in ['E','P'];
        If Ch='E' then FullMatch:=True else FullMatch:=False;
        GotoXY(2,2); ClrEol;
        KeyCat:=False;
        Write('    Print a catalog listing on printer?  Y/N');
        If YES then KeyCat:=True;
      End Else begin
        GotoXY(5,2);
        Write('File Name to Search For:');
        S1:='';
        RestoreCursor;
        InputStr(S1,12,30,2,Af,[#13],Ch);
        For I:= 1 to Length(S1) do S1[I]:=Upcase(S1[I]);
        I:=Pos('.',S1);
        If I>0 then
          While Pos('.',S1)<>9 do S1:=Copy(S1,1,I-1)+' '+Copy(S1,I,length(S1));
        I:=Pos('.',S1);
        If I=9 then Delete(S1,I,1);
      End;
      NormVideo;
      BigWindow(1,1,80,25);
      RestoreScreen;
      FKey:=S1;
      SKey:=S1;
      HideCursor;
    End; { procedure EnterSearch }

    PROCEDURE FileSearch;
      Begin
        SearchKey(CIndex,RecNum,FKey);
        S1:=Copy(FKey,1,11);
        Done:=False;
        If NOT OK then begin
          Boop;
          GotoXY(1,1); Write(S2,' not found');
          If NOT OK then begin
            FKey:='';
            ClearKey(CIndex);
            SearchKey(CIndex,RecNum,FKey);
          End;
        End;
        If Ok then begin
        Repeat
          If NOT Printed then ShowData(RecNum);
          Printed:=False;
          GotoXY(1,23);
          If (FileRec.FileName=FileRec.ParentName) and
             (NOT FileRec.StandAlone) and (NOT ChildFlag) then begin
             LowVideo;
             Write('MAIN FILE DISPLAYED...  ENTER <A> TO FIND ASSOCIATED FILES');
             Beep;
             NormVideo;
          End Else If ChildFlag then begin
            If ChildCount=0 then ChildFlag:=False;
            LowVideo;
            Write('Showing ',ChildMatch,' Associated File ');
            NormVideo;
            Write(ChildSelect,' of ',ChildCount,' <--');
          End Else Write('Browsing Records Currently Entered in FILECAT Database...');
          ClrEol;
          GotoXY(1,25);
          If ChildFlag then Write('        <*> Print Record  <S> Search for Different File Name')
            Else Write('        <E> Edit  <*> Print Record  <S> Search');
          ClrEol;
          GotoXY(1,24);
          If ChildFlag then Write('Press:  <N> Next  <P> Previous  <Q> Quit ')
            Else Write('Press:  <N> Next  <P> Previous  <Q> Quit  <D> Delete  ');
          ClrEol;
          Repeat
            Read(Kbd,Ch);
            Ch:=Upcase(Ch);
            If NOT (Ch in ['N','P','Q','D','E','*','S','A']) then Boop;
            Until Ch in ['N','P','Q','D','E','*','S','A'];
            Case Ch of
              'Q' : Done:=True;
              'N' : Begin
                      If ChildFlag then begin
                        ChildSelect:=ChildSelect+1;
                        If ChildSelect>ChildCount then ChildSelect:=1;
                        RecNum:=ChildArray[ChildSelect].CNum;
                      End Else Begin
                        NextKey(CIndex,RecNum,FKey);
                        GotoXY(1,1); Write(ConstStr(' ',40)); GotoXY(1,1);
                        If NOT OK then Write('First Record');
                        If NOT OK then NextKey(CIndex,RecNum,FKey);
                      End;
                    End;
              'P' : Begin
                      If ChildFlag then begin
                        ChildSelect:=ChildSelect-1;
                        If ChildSelect<1 then ChildSelect:=ChildCount;
                        RecNum:=ChildArray[ChildSelect].CNum;
                      End Else Begin
                        PrevKey(CIndex,RecNum,FKey);
                        GotoXY(1,1); Write(ConstStr(' ',40)); GotoXY(1,1);
                        If NOT OK then Write('Last Record ');
                        If NOT OK then PrevKey(CIndex,RecNum,FKey);
                      End;
                    End;
              'D' : If NOT ChildFlag then Begin
                      Beep;
                      TextColor(7+Blink);
                      Write('Are you sure? Y/N ');
                      NormVideo;
                      RestoreCursor;
                      If YES then begin
                        DeleteRec(CFile,RecNum);
                        DeleteKey(CIndex,RecNum,FKey);
                        SearchKey(CIndex,RecNum,FKey);
                      End;
                      HideCursor;
                    End;
              'E' : If NOT ChildFlag then Begin
                      FTemp:=FileRec;
                      Textcolor(7+blink);
                      GotoXY(1,1); ClrEol;
                      Write('EDITING');
                      Normvideo;
                      RestoreCursor;
                      EnterData;
                      FileRec:=FTemp;
                      AddKeywords;
                      PutRec(CFile,RecNum,FileRec);
                      HideCursor;
                      GotoXY(1,1); ClrEol;
                      GotoXY(60,1);Write('Browse / Edit');
                    End;
              '*' : Begin
                      GotoXY(1,1); Write(ConstStr(' ',40));
                      PrintRec;
                      Printed:=True;
                    End;
              'S' : Begin
                      ChildFlag:=False;
                      GotoXY(1,1); Write(ConstStr(' ',40));
                      S2:=FKey;
                      EnterSearch;
                      S1:=FKey;
                      ClearKey(CIndex);
                      SearchKey(CIndex,RecNum,FKey);
                      If (Copy(FKey,1,Length(S1))<>S1) or (NOT OK) then begin
                        Boop;
                        GotoXY(1,1); Write(S1,' not found');
                        If NOT OK then begin
                          FKey:=S2;
                          ClearKey(CIndex);
                          SearchKey(CIndex,RecNum,FKey);
                        End;
                      End;
                      NormVideo;
                    End;
              'A' : If (FileRec.FileName=FileRec.ParentName)
                    and (NOT FileRec.StandAlone)
                    and (NOT ChildFlag) then begin
                      CloseFiles;
                      ReportChoice:='c';
                      ChildCount:=0;
                      ChildSelect:=0;
                      ChildMatch:=FileRec.ParentName;
                      GotoXY(1,1); Write('Please wait... searching');
                      I:=TurboSort(SizeOf(SortKey));
                      OpenFiles;
                      ChildFlag:=True;
                      GotoXY(1,1);ClrEol;
                      If (I=0) and (ChildCount>0) then begin
                        ChildFlag:=True;
                        ChildSelect:=1;
                        RecNum:=ChildArray[ChildSelect].CNum;
                      End Else begin
                        Boop;
                        Textcolor(7+blink);
                        If I<>0 then Write('TURBOSORT ERROR ',I)
                          Else Write('NO ASSOCIATED FILES FOUND...');
                        Normvideo;
                        HideCursor;
                        SearchKey(CIndex,RecNum,FKey);
                      End;
                      GotoXY(60,1);Write('Browse / Edit');
                    End Else Boop;
            End;
          Until Done;
          ChildFlag:=False;
        End;
      End; { procedure FileSearch }

    PROCEDURE KeywordSearch;
      Begin
        MatchCount:=0;
        J:=0;
        ClearKey(CIndex);
        NextKey(CIndex,RecNum,FKey);
        While OK do begin
          GetRec(CFile,RecNum,FTemp);
          LowVideo;
          GotoXY(1,1);
          Write('SEARCHING: Reading ',FTemp.FileName);
          Matched:=False;
          If FullMatch = True then begin
            S1:=FTemp.Keys;
            Repeat
              Parse(S1,S2);
              If SKey=S2 then Matched:=True;
            Until (Matched=True) or (Length(S1)=0)
          End Else If Pos(SKey,FTemp.Keys)>0 then Matched:=True;
          Done:=False;
          If Matched then MatchCount:=MatchCount+1;
          If Matched and KeyCat then begin
            Boop;
            Normvideo;
            ShowData(RecNum);
            GotoXY(1,23);
            Write('Found ');
            If FullMatch then Write('exact ') else Write('partial ');
            Write('match with Keyword "',SKey,'"');
            If J=0 then begin
              Write(Lst,TDate,' Catalog of files with ');
              If FullMatch then Write(Lst,'exact ') else Write(Lst,'partial ');
              WriteLn(Lst,'match with Keyword "',SKey,'"');
              WriteLn(Lst,ConstStr('-',79));
              WriteLn(Lst);
              J:=3;
            End;
            With FileRec do begin
              S:=FileName;
              Repeat
                For I:=1 to Length(S) do If S[I]=' ' then Delete(S,I,1);
              Until I=Length(S);
              Write(Lst,S,ConstStr(' ',14-Length(S)));
              Size := (FileSize[1] * 1.0) +
                      (FileSize[2] * 256.0) +
                      (FileSize[3] * 65536.0);
              Year := (FileDate shr 9) + 80;
              Month := (FileDate shl 7) shr 12;
              Day := (FileDate shl 11) shr 11;
              Hour := FileTime shr 11;
              If Hour >= 12 then begin
                AP := 'p';
                Hour := Hour - 12;
              End Else AP := 'a';
              If Hour = 0 then Hour := 12;
              Minute := (FileTime shl 5) shr 10;
              Write(Lst,Size:1:0,' Bytes  ');
              Write(Lst,Hour:2,':');
              If Minute < 10 then Write(Lst,'0');
              Write(Lst,Minute,ap,'  ');
              Write(Lst,Month:2,'-');
              If Day < 10 then Write(Lst,'0');
              Write(Lst,Day,'-',Year,'   ');
              WriteLn(Lst,'(',VolPath,')');
              J:=J+1;
              S:=Description[1]+' '+Description[2]+' '+Description[3]+' ';
              I:=3;
              If Length(S)<160 then begin
                S:=S+Description[4];
                I:=4;
              End;
              While S<>'' do begin
                S1:=Copy(S,1,64);
                K:=Length(S1);
                If K=64 then While (S1[K]<>' ') and (K<>0) do K:=K-1;
                S1:=Copy(S1,1,K);
                Delete(S,1,K);
                If Length(S1)>0 then begin
                  WriteLn(Lst,ConstStr(' ',14),S1);
                  J:=J+1;
                End;
                If (Length(S)<160) and (I<>4) then begin
                  S:=S+Description[4];
                  I:=4;
                End;
              End;
              If J>=53 then begin
                Write(Lst,#12);
                J:=0;
              End;
            End;
          End Else If Matched then Repeat
            Beep;
            Normvideo;
            If NOT Printed then ShowData(RecNum);
            Printed:=False;
            GotoXY(1,23);
            Write('Found ');
            If FullMatch then Write('exact ') else Write('partial ');
            Write('match with Keyword "',SKey,'"');
            GotoXY(1,25);
            Write('        <E> Edit  <*> Print Record  <C> or <N> Continue Search');
            GotoXY(1,24);
            Write('Press:  <Q> Quit  <D> Delete  ');
            ClrEol;
            Repeat
              Read(Kbd,Ch);
              Ch:=Upcase(Ch);
              If NOT (Ch in ['Q','D','E','*','C','N']) then Boop;
            Until Ch in ['Q','D','E','*','C','N'];
            Case Ch of
              'Q' : Exit;
              'D' : Begin
                      Beep;
                      TextColor(7+Blink);
                      Write('Are you sure? Y/N ');
                      NormVideo;
                      RestoreCursor;
                      If YES then DeleteRec(CFile,RecNum);
                      HideCursor;
                    End;
              'E' : Begin
                      Textcolor(7+blink);
                      GotoXY(1,1); ClrEol;
                      Write('EDITING');
                      Normvideo;
                      RestoreCursor;
                      EnterData;
                      FileRec:=FTemp;
                      PutRec(CFile,RecNum,FileRec);
                      HideCursor;
                      GotoXY(1,1);ClrEol;
                      GotoXY(60,1);Write('Keyword Search');
                    End;
              '*' : Begin
                      GotoXY(1,1); Write(ConstStr(' ',40));
                      PrintRec;
                      Printed:=True;
                      GotoXY(1,1);ClrEol;
                      GotoXY(60,1);Write('Keyword Search');
                    End;
              'C' : Done:=True;
              'N' : Done:=True;
            End;
          Until Done;
          NextKey(CIndex,RecNum,FKey);
        End;
        GotoXY(1,1); Write(ConstStr(' ',40));
        GotoXY(1,23);ClrEol;
        GotoXY(1,24);ClrEol;
        GotoXY(1,25);ClrEol;
        Boop;
        LowVideo;
        GotoXY(1,23);Write(MatchCount);
        If NOT FullMatch then Write(' partial');
        Write(' match(es) found for Keyword "',SKey,'"');
        NormVideo;
        GotoXY(1,24);Write('END OF FILE... Press any key to return to menu');
        Read(Kbd,ch);
        If KeyCat and (J>0) then begin
          J:=0;
          Write(Lst,#12);
        End;
      End; { procedure KeywordSearch }

  Begin
    ShowScreen;
    EnterSearch;
    Printed:=False;
    GotoXY(60,1);
    If KeySearch then Write('Keyword Search') Else Write('Browse / Edit');
    S2:=FKey;
    OpenFiles;
    ChildFlag:=False;
    If KeySearch then KeywordSearch else FileSearch;
    CloseFiles;
    RestoreCursor;
  End; { procedure BrowseEdit }

OVERLAY PROCEDURE PrintAll;
  VAR RecNum:Integer;
      Done:Boolean;
  Begin
    ShowScreen;
    HideCursor;
    GotoXY(1,24); ClrEol; Beep;
    Write('Position printer at beginning of new page.  Press any key when ready.');
    Read(Kbd,Ch);
    GotoXY(1,24); ClrEol;
    If NOT PRTest then repeat
      Beep;
      GotoXY(1,24); ClrEol;
      Write('PRINTER NOT READY. Please correct and press any key when ready or ESC to Quit.');
      Read(Kbd,Ch);
      GotoXY(1,24); ClrEol;
      If (Ch=#27) and (NOT Keypressed) then Exit;
    until PRTest;
    HideCursor;
    GotoXY(60,1);Write('Printing All Files');
    FKey:='';
    Done:=False;
    PrintCount:=0;
    OpenFiles;
    ClearKey(CIndex);
    SearchKey(CIndex,RecNum,FKey);
    If Ok then Repeat
      LowVideo;
      GotoXY(1,24);
      Write('Press <ESC> to Abort Printing...');
      NormVideo;
      ShowData(RecNum);
      PrintRec;
      NextKey(CIndex,RecNum,FKey);
      If KeyPressed then begin
        Read(Kbd,Ch);
        If (Ch=#27) and (NOT Keypressed) then begin
          GotoXY(1,24); ClrEol;
          Write('Escape key detected.  Abort Printing?  Y/N');
          If Yes then Done:=True;
          GotoXY(1,24); ClrEol;
        End;
      End;
    Until (NOT OK) or Done;
    CloseFiles;
    RestoreCursor;
  End; { procedure PrintAll }

OVERLAY PROCEDURE DiskCatalog;
  LABEL 1;
  VAR S,S1,S2,SKey,FKey:AnyStr;
      RecNum:Integer;
      Done,PrintIt,FullMatch,Matched,FileCompare:Boolean;
      I,J,K,MatchCount,DeleteCount:Integer;

  PROCEDURE EnterSearch;
    Begin
      SaveScreen;
      DrawBox(10,70,17,21);
      BigWindow(11,18,69,20);
      If MonitorType = 7 then begin
        HideCursor;
        For I:=1 to 3 do begin
          GotoXY(1,I);
          Write(ConstStr(' ',59));
        End;
        RestoreCursor;
      End Else ClrScr;
      LowVideo;
      FileCompare:=False;
      PrintIt:=False;
      GotoXY(2,2);
      HideCursor;
      Write(' Compare source files to database for deleted files?  Y/N');
      Beep;
      If YES then begin
        RestoreCursor;
        FileCompare:=True;
        INT24On;
        {$I-}
        ChDir(SourceDirectory);
        {$I+}
        I:=INT24Result;
        INT24Off;
        If I<>0 then begin
          GotoXY(2,2);ClrEol;
          Write(' Drive not ready... press any key to continue.');
          Beep;
          Read(Kbd,Ch);
          I:=9999;
        End;
        NormVideo;
        BigWindow(1,1,80,25);
        RestoreScreen;
        If SourceDirectory[1] in ['A','B'] then SKey:=OldVolumeName
          Else SKey:=SourceDirectory;
        Exit;
      End;
      RestoreCursor;
      PrintIt:=True;
      GotoXY(2,2);ClrEol;
      Write(' Disk/Dir to Search For:');
      Beep;
      NormVideo;
      S1:=OldVolumeName;
      FirstCharDelete:=True;
      InputStr(S1,24,30,2,Af,[#13],Ch);
      If S1='' then I:=9999;
      FirstCharDelete:=False;
      HideCursor;
      BigWindow(1,1,80,25);
      RestoreScreen;
      FKey:=S1;
      SKey:=S1;
      HideCursor;
    End; { procedure EnterSearch }

    PROCEDURE KeywordSearch;
      Begin
        MatchCount:=0;
        DeleteCount:=0;
        J:=0;
        ClearKey(CIndex);
        NextKey(CIndex,RecNum,FKey);
        While OK do begin
          GetRec(CFile,RecNum,FTemp);
          LowVideo;
          GotoXY(1,1);
          Write('SEARCHING: Reading ',FTemp.FileName);
          Matched:=False;
          If SKey=FTemp.VolPath then Matched:=True;
          If Matched then MatchCount:=MatchCount+1;
          If Matched and FileCompare then begin
            Normvideo;
            ShowData(RecNum);
            S1:=Copy(FTemp.FileName,1,Pos('.',FTemp.FileName)-1);
            S1:=S1+ConstStr(' ',8-Length(S1));
            S2:=Copy(FTemp.FileName,Pos('.',FTemp.FileName)+1,3);
            S2:=S2+ConstStr(' ',3-Length(S2));
            Done:=False;
            For I := 1 to EntryNum do begin
              If (S1=Entry[I].EName) and (S2=Entry[I].EExt) then Done:=True;
            End;
            If NOT Done then begin
              If J=0 then begin
                WriteLn(Lst,TDate,' -- Listing of files in Filecat database NOT on ',SKey);
                WriteLn(Lst,ConstStr('-',79));
                WriteLn(Lst);
                J:=3;
              End;
              With FileRec do begin
                S:=FileName;
                Repeat
                  For I:=1 to Length(S) do If S[I]=' ' then Delete(S,I,1);
                Until I=Length(S);
                Write(Lst,'[ ] CHECK --> ',S,ConstStr(' ',14-Length(S)));
                Size := (FileSize[1] * 1.0) +
                        (FileSize[2] * 256.0) +
                        (FileSize[3] * 65536.0);
                Year := (FileDate shr 9) + 80;
                Month := (FileDate shl 7) shr 12;
                Day := (FileDate shl 11) shr 11;
                Hour := FileTime shr 11;
                If Hour >= 12 then begin
                  AP := 'p';
                  Hour := Hour - 12;
                End Else AP := 'a';
                If Hour = 0 then Hour := 12;
                Minute := (FileTime shl 5) shr 10;
                Write(Lst,Size:1:0,' Bytes  ');
                Write(Lst,Hour:2,':');
                If Minute < 10 then Write(Lst,'0');
                Write(Lst,Minute,ap,'  ');
                Write(Lst,Month:2,'-');
                If Day < 10 then Write(Lst,'0');
                Write(Lst,Day,'-',Year,'   ');
                WriteLn(Lst,'(Record #',RecNum,')');
                J:=J+1;
                If J>=53 then begin
                  Write(Lst,#12);
                  J:=0;
                End;
              End;
            End;
          End Else If Matched then begin
            Boop;
            Normvideo;
            ShowData(RecNum);
            GotoXY(1,23);
            Write('Found match with Disk/Dir "',SKey,'"');
            If J=0 then begin
              WriteLn(Lst,TDate,' Catalog of files on ',SKey);
              WriteLn(Lst,ConstStr('-',79));
              WriteLn(Lst);
              J:=3;
            End;
            With FileRec do begin
              S:=FileName;
              Repeat
                For I:=1 to Length(S) do If S[I]=' ' then Delete(S,I,1);
              Until I=Length(S);
              Write(Lst,S,ConstStr(' ',14-Length(S)));
              Size := (FileSize[1] * 1.0) +
                      (FileSize[2] * 256.0) +
                      (FileSize[3] * 65536.0);
              Year := (FileDate shr 9) + 80;
              Month := (FileDate shl 7) shr 12;
              Day := (FileDate shl 11) shr 11;
              Hour := FileTime shr 11;
              If Hour >= 12 then begin
                AP := 'p';
                Hour := Hour - 12;
              End Else AP := 'a';
              If Hour = 0 then Hour := 12;
              Minute := (FileTime shl 5) shr 10;
              Write(Lst,Size:1:0,' Bytes  ');
              Write(Lst,Hour:2,':');
              If Minute < 10 then Write(Lst,'0');
              Write(Lst,Minute,ap,'  ');
              Write(Lst,Month:2,'-');
              If Day < 10 then Write(Lst,'0');
              Write(Lst,Day,'-',Year,'   ');
              WriteLn(Lst,'(',VolPath,')');
              J:=J+1;
              S:=Description[1]+' '+Description[2]+' '+Description[3]+' ';
              I:=3;
              If Length(S)<160 then begin
                S:=S+Description[4];
                I:=4;
              End;
              While S<>'' do begin
                S1:=Copy(S,1,64);
                K:=Length(S1);
                If K=64 then While (S1[K]<>' ') and (K<>0) do K:=K-1;
                S1:=Copy(S1,1,K);
                Delete(S,1,K);
                If (Length(S1)>0) and (S1<>'   ') then begin
                  WriteLn(Lst,ConstStr(' ',14),S1);
                  J:=J+1;
                End;
                If (Length(S)<160) and (I<>4) then begin
                  S:=S+Description[4];
                  I:=4;
                End;
              End;
              If J>=53 then begin
                Write(Lst,#12);
                J:=0;
              End;
            End;
          End;
          NextKey(CIndex,RecNum,FKey);
        End;
        GotoXY(1,1); Write(ConstStr(' ',40));
        GotoXY(1,23);ClrEol;
        GotoXY(1,24);ClrEol;
        GotoXY(1,25);ClrEol;
        Boop;
        LowVideo;
        GotoXY(1,23);Write(MatchCount);
        Write(' match(es) found for Disk/Directory "',SKey,'"');
        NormVideo;
        GotoXY(1,24);Write('END OF FILE... Press any key to return to menu');
        Read(Kbd,ch);
        If J>0 then begin
          J:=0;
          Write(Lst,#12);
        End;
      End; { procedure KeywordSearch }

  Begin
    ShowScreen;
    If NOT PRTest then repeat
      Beep;
      GotoXY(1,24); ClrEol;
      Write('PRINTER NOT READY. Please correct and press any key when ready or ESC to Quit.');
      Read(Kbd,Ch);
      GotoXY(1,24); ClrEol;
      If (Ch=#27) and (NOT Keypressed) then Exit;
    until PRTest;
    OpenFiles;
    EnterSearch;
    If I=9999 then goto 1;
    If FileCompare=True then begin
      BuildArray;
      If EntryNum=0 then goto 1;
    End;
    GotoXY(60,1);
    Write('Disk Catalog');
    KeywordSearch;
1:
    CloseFiles;
    RestoreCursor;
    ChDir(EntryDirectory);
  End; { procedure DiskCatalog }