OVERLAY FUNCTION SelectKeyword : Str15;
  VAR S:Str15;
      I,N:Integer;
      KArray:Array[1..20] of Str15;
      Done,First:Boolean;
      Ch2:Char;
  Begin
    SaveScreen;
    DrawBox(63,79,1,25);
    BigWindow(64,2,78,24);
    If Monitortype=7 then begin
      HideCursor;
      For I:=1 to 23 do begin
        GotoXY(1,I);
        Write(ConstStr(' ',15));
      End;
      RestoreCursor;
    End Else ClrScr;
    HideCursor;
    GotoXY(1,21); Write('<A...Z> Display');
    GotoXY(1,22); Write('<Enter> Select');
    GotoXY(1,23); Write(' <ESC>  Quit');
    Done:=False;
    First:=False;
    FillChar(KArray,SizeOf(KArray),#0);
    ClearKey(KIndex);
    S:='A';
    N:=1;
    SearchKey(KIndex,I,S);
    If OK then KArray[N]:=S;
    If OK then Repeat
      NextKey(KIndex,I,S);
      If NOT OK then NextKey(KIndex,I,S);
      N:=N+1;
      KArray[N]:=S;
    Until N=20;
    For I:=1 to N do begin
      GotoXY(1,I);
      If I=(N div 2) then begin
        TextBackGround(7);
        TextColor(0);
      End Else Lowvideo;
      Write(KArray[I]);ClrEol;
    End;
    Repeat
      Read(Kbd,Ch);
      If Ch in ['a'..'z'] then Ch:=Upcase(Ch);
      Case Ch of
        #27 : If KeyPressed then begin
              Ch:=#0;
              Read(Kbd,Ch2);
              Case Ch2 of
                #72 : Begin
                        S:=KArray[1];
                        SearchKey(KIndex,I,S);
                        PrevKey(KIndex,I,S);
                        PrevKey(KIndex,I,S);
                        N:=0;
                        Repeat
                          NextKey(KIndex,I,S);
                          If NOT OK then NextKey(KIndex,I,S);
                          N:=N+1;
                          KArray[N]:=S;
                        Until N=20;
                      End;
                #80 : Begin
                        S:=KArray[1];
                        SearchKey(KIndex,I,S);
                        N:=0;
                        Repeat
                          NextKey(KIndex,I,S);
                          If NOT OK then NextKey(KIndex,I,S);
                          N:=N+1;
                          KArray[N]:=S;
                        Until N=20;
                      End;
                #73 : Begin
                        S:=KArray[1];
                        SearchKey(KIndex,I,S);
                        For I:=1 to 21 do PrevKey(KIndex,I,S);
                        N:=0;
                        Repeat
                          NextKey(KIndex,I,S);
                          If NOT OK then NextKey(KIndex,I,S);
                          N:=N+1;
                          KArray[N]:=S;
                        Until N=20;
                      End;
                #81 : Begin
                        S:=KArray[20];
                        SearchKey(KIndex,I,S);
                        N:=0;
                        Repeat
                          NextKey(KIndex,I,S);
                          If NOT OK then NextKey(KIndex,I,S);
                          N:=N+1;
                          KArray[N]:=S;
                        Until N=20;
                      End;
              End;
              End;
        ' '..'Z' : Begin
                     FillChar(KArray,SizeOf(KArray),#0);
                     ClearKey(KIndex);
                     S:=Ch;
                     N:=1;
                     SearchKey(KIndex,I,S);
                     If OK then KArray[N]:=S;
                     If OK then Repeat
                       NextKey(KIndex,I,S);
                       If NOT OK then NextKey(KIndex,I,S);
                       N:=N+1;
                       KArray[N]:=S;
                     Until N=20;
                   End;
      End;
      For I:=1 to N do begin
        GotoXY(1,I);
        If I=(N div 2) then begin
          TextBackGround(7);
          TextColor(0);
        End Else Lowvideo;
        Write(KArray[I]);ClrEol;
      End;
    Until Ch in [#27,#13];
    If Ch=#27 then SelectKeyword:='' Else SelectKeyword:=KArray[N div 2];
    BigWindow(1,1,80,25);
    RestoreCursor;
    RestoreScreen;
  End; { function SelectKeyword }

OVERLAY PROCEDURE AddKeywords;
  VAR S1,S2:AnyStr;
      S3:Str15;
      I:Integer;
  Begin
    S1:=FTemp.Keys;
    I:=1;
    Repeat
      Parse(S1,S2);
      If S2<>'' then begin
        S3:=S2;
        FindKey(KIndex,I,S3);
        If NOT OK then AddKey(KIndex,I,S3);
      End;
    Until S1='';
  End; { procedure AddKeywords }

OVERLAY PROCEDURE DeleteTransfer;
  VAR S:AnyStr;
  Begin
    S:=EntryDirectory;
    If S[Length(S)]<>'\' then S:=S+'\';
    S:=S+'TRANSFER.DAT';
    If Exist(S) then begin
      Assign(ExFile,S);
      Erase(ExFile);
      S:=EntryDirectory;
      If S[Length(S)]<>'\' then S:=S+'\';
      S:=S+'TRANSFER.IXN';
      Assign(ExFile,S);
      Erase(ExFile);
    End;
  End; { procedure DeleteTransfer }

OVERLAY PROCEDURE AddTransfer(Location:Str80);
  VAR N,RecNum:Integer;
  Begin
    ChDir(EntryDirectory);
(*******
    If Exist('TRANSFER.DAT') then begin
      Assign(ExFile,'TRANSFER.DAT');
      Erase(ExFile);
    End;
    If Exist('TRANSFER.DXT') then begin
      Assign(ExFile,'TRANSFER.DXT');
      Erase(ExFile);
    End;
*******)
    OpenFile(CFile,'FILECAT.DAT',SizeOf(FRec));
    OpenIndex(CIndex,'FILECAT.IXN',14,1);
    Location:=Location+'TRANSFER.DAT';
    OpenFile(CFile2,Location,SizeOf(FRec));
    For N := 1 to FileLen(CFile2)-1 do begin
      GetRec(CFile2,N,FTemp);
      If FTemp.Status=0 then begin
        FKey:=Copy(FTemp.FileName,1,8)+Copy(FTemp.FileName,10,3);
        FKey:=FKey+ConstStr(' ',13-Length(FKey));
        If FTemp.StandAlone then FKey:=FKey+'1' Else FKey:=FKey+'0';
        GotoXY(1,11);ClrEol;
        Write('Adding ',FKey);
        AddRec(CFile,RecNum,FTemp);
        If OK then AddKey(CIndex,RecNum,FKey);
        If NOT OK then begin
          DeleteRec(CFile,RecNum);
          GotoXY(1,11);ClrEol;
          Beep;
          Write('Error writing Record');
        End;
      End;
    End;
    GotoXY(1,11); ClrEol;
    CloseFile(CFile);
    CloseIndex(CIndex);
    CloseFile(CFile2);
  End; { procedure AddTransfer }

OVERLAY PROCEDURE MoveFiles;
  VAR N,RecNum:Integer;
      S:Str80;
  Begin
    ChDir(EntryDirectory);
    OpenFile(CFile,'TRANSFER.DAT',SizeOf(FRec));
    S:=SourceDirectory;
    N:=Length(S);
    If S[N]<>'\'then S:=S+'\';
    S:=S+'TRANSFER.DAT';
    MakeFile(CFile2,S,SizeOf(FRec));
    CloseFile(CFile2);
    OpenFile(CFile2,S,SizeOf(FRec));
    For N := 1 to FileLen(CFile)-1 do begin
      GetRec(CFile,N,FTemp);
      If FTemp.Status=0 then begin
        GotoXY(29,24);
        Write('Adding ',FTemp.FileName);
        AddRec(CFile2,RecNum,FTemp);
      End;
    End;
    GotoXY(1,24); ClrEol;
    CloseFile(CFile);
    CloseFile(CFile2);
  End; { procedure MoveFiles }

OVERLAY PROCEDURE SetEpson;
  CONST N = 26;
  VAR TempCh :Char;
      Left,I : Integer;
      S:AnyStr;
  Begin
    If Monitortype=7 then begin
      For I:=7 to 25 do begin
        GotoXY(1,I);
        ClrEol;
      End;
    End Else begin
      BigWindow(1,7,80,25);
      ClrScr;
      BigWindow(1,1,80,25);
    End;
    If not PrTest then Repeat
      Beep;
      GotoXY(20,15);
      WriteLn('Printer does not appear to be ready');
      GotoXY(20,16);
      WriteLn('Press any key when ready or ESC to return to menu');
      Repeat until KeyPressed;
      Read(Kbd,TempCh);
      If (TempCh = #27) and KeyPressed then Read(Kbd,TempCh);
      If TempCh = #27 then Exit;
      If Monitortype=7 then begin
        For I:=9 to 25 do begin
          GotoXY(1,I);
          ClrEol;
        End;
      End Else begin
        BigWindow(1,9,80,25);
        ClrScr;
        BigWindow(1,1,80,25);
      End;
    Until PrTest;
    GotoXY(N,10); WriteLn('1 -- Pica  (10 chars/inch)');
    GotoXY(N,11); WriteLn('2 -- Elite (12 chars/inch)');
    GotoXY(N,12); WriteLn('3 -- Cond  (17 chars/inch)');
    GotoXY(N,13); WriteLn('4 -- Set Left Margin');
    LowVideo;
    GotoXY(N,16); WriteLn('9 -- Return to Main Menu');
    NormVideo;
    GotoXY(N,21); Write('Enter your selection: [ ]');
    Left:=1;
    TempCh:='1';
    Write(Lst,#27,'@',#13);
    Write(Lst,#27,'l',Chr(Left),#13);
    Repeat
      GotoXY(N,23);ClrEol;
      Write('Left Margin set at ',Left,'  ');
      Case TempCh of
        '1' : Write('Pica');
        '2' : Write('Elite');
        '3' : Write('Condensed');
      End;
      GotoXY(N+23,21);
      Read(Kbd,TempCh);
      Write(TempCh);
      Case TempCh of
        '1' : Write(Lst,#27,#18,#27,'P',#13);
        '2' : Write(Lst,#27,#18,#27,'M',#13);
        '3' : Write(Lst,#27,'P',#27,#15,#13);
        '4' : Begin
                Repeat
                  GotoXY(N,23);ClrEol;
                  Write('Set left margin at how many characters: ');
                  ReadLn(S);
                  Val(S,Left,I);
                  If (Left<0) or (Left>20) then I:=1;
                  If I<>0 then Boop;
                Until I=0;
                Write(Lst,#27,'l',Chr(Left),#13);
              End;
        '9' : ;
      Else Boop;
      End;
    Until TempCh = '9';
  End; {SetEpson}

OVERLAY FUNCTION SelectFile: Integer;
  VAR TopLine,
      BottomLine,
      OldTop,
      Current,
      Last,I       : Integer;
      DoAll : Boolean;
  Begin
    If KeyPressed then Repeat
      Read(Kbd,Ch);
    Until NOT Keypressed;
    Current:=1;
    Last:=1;
    TopLine:=1;
    BottomLine:=20;
    If BottomLine>EntryNum then BottomLine:=EntryNum;
    DoAll:=True;
    HideCursor;
    Repeat
      If DoAll then begin
        If Monitortype = 7 then begin
          For I:= 1 to 23 do begin
            GotoXY(1,I);
            Write(ConstStr(' ',13));
          End;
          GotoXY(1,1);
        End Else ClrScr;
        For I:= TopLine to BottomLine do begin
          LowVideo;
          If Entry[I].EStatus=1 then TextColor(1);
          If I=Current then begin
            TextBackGround(7);
            If Entry[I].EStatus=1 then TextColor(1) Else TextColor(0)
          End;
          WriteLn(Entry[I].EName,' ',Entry[I].EExt);
        End;
        OldTop:=TopLine;
      End Else begin
        GotoXY(1,1+(Current-TopLine));
        TextBackGround(7);
        If Entry[Current].EStatus=1 then TextColor(1) Else TextColor(0);
        WriteLn(Entry[Current].EName,' ',Entry[Current].EExt);
        OldTop:=TopLine;
      End;
      LowVideo;
      GotoXY(1,21);ClrEol;
      If BottomLine<EntryNum then Write('  ',#25,' MORE ',#25);
      GotoXY(1,22);
      TextColor(1);
      Write(' Blue ');
      LowVideo;
      Write('= Dup');
      Last:=Current;
      Read(Kbd,Ch);
      If (Ch=#27) and KeyPressed then Read(Kbd,Ch);
      DoAll:=False;
      Case Ch of
        #72 : Current:=Current-1;       { up }
        #80 : Current:=Current+1;       { down }
        #71 : Current:=TopLine;         { home }
        #79 : Current:=BottomLine;      { end }
        #73 : Begin
                BottomLine:=BottomLine-20;   { pgup }
                DoAll:=True;
              End;
        #81 : Begin
                BottomLine:=BottomLine+20;   { pgdn }
                DoAll:=True;
              End;
        'S','s' : Begin
                    QuickSortRecord(Entry,EntryNum);
                    Current:=1;
                    DoAll:=True;
                  End;
        #13 : ;
      Else Boop;
      End;
      GotoXY(1,1+(Last-TopLine));
      LowVideo;
      If Entry[Last].EStatus=1 then TextColor(1);
      WriteLn(Entry[Last].EName,' ',Entry[Last].EExt);
      GotoXY(1,1);
      If (Current=BottomLine+1) and (Current<=EntryNum) then DelLine;
      If (Current=TopLine-1) and (Current>0) then begin
        InsLine;
        GotoXY(1,21);
        DelLine;
      End;
      If Current<1 then Current:=1;
      If Current>EntryNum then Current:=EntryNum;
      If Current>TopLine+19 then BottomLine:=Current;
      If Current<TopLine then TopLine:=Current;
      If TopLine<>OldTop then BottomLine:=Topline+19;
      If BottomLine<20 then BottomLine:=20;
      If BottomLine>EntryNum then BottomLine:=EntryNum;
      TopLine:=BottomLine-19;
      If TopLine<1 then TopLine:=1;
      If Current<TopLine then Current:=TopLine;
      If Current>BottomLine then Current:=BottomLine;
    Until Ch in [#13,#27,#59];
    RestoreCursor;
    If Ch=#27 then SelectFile:=0
      Else If Ch=#59 then Selectfile:=-1
      Else SelectFile:=Current;
  End; { function SelectFile }

OVERLAY PROCEDURE volume(drivelet:Char;AskChange:Boolean);
  TYPE
    extendfcb = ARRAY[0..43] OF Char;
  VAR
    drivenam : STRING[3];
    drive : byte;
    i,filetime,filedate : Integer;
    s : AnyStr;
    haslabel : Boolean;
    labl : string[11];
    dta, xfcb, sfcb : extendfcb;

  PROCEDURE initfcb(VAR x : extendfcb; namechar : Char);
    {initialize an extended fcb}
    VAR
      i : Integer;
    BEGIN
      x[0] := Chr(255);     {flag for extended FCB}
      FOR i := 1 TO 5 DO x[i] := Chr(0);
      x[6] := Chr(8);       {specifies that we want volume label}
      x[7] := Chr(0);       {where drive number goes}
      FOR i := 8 TO 18 DO x[i] := namechar;
      FOR i := 19 TO 43 DO x[i] := Chr(0);
    END;                    {initfcb}

  BEGIN
    initfcb(sfcb, '?');     {initialize buffers}
    initfcb(xfcb, ' ');
    Drive:=Ord(DriveLet)-64;
    sfcb[7] := Chr(drive);
    xfcb[7] := Chr(drive);
    regs.ax := $1A00;
    regs.ds := Seg(dta[0]);
    regs.dx := Ofs(dta[0]);
    MsDos(regs);             {SET UP DISK TRANSFER AREA FOR FILENAMES}

    regs.dx := Ofs(sfcb[0]);
    regs.ax := $1100;
    MsDos(regs);             {search for volume entry}

    IF Lo(regs.ax) = $FF THEN BEGIN
      haslabel := False;
      OldVolumeName := '<NONE>';
      OldVolumeNameDate := '';
      GotoXY(1,11); ClrEol;
      WriteLn('Diskette in drive ',drive,' has no label... please enter.');
    END ELSE BEGIN
      haslabel := True;
      OldVolumeName:='';
      FOR i := 1 TO 11 DO OldVolumeName:=OldVolumeName+(dta[7+i]);
      I:=11;
      While (OldVolumeName[I]=' ') and (I>0) do begin
        Delete(OldVolumeName,I,1);
        I:=I-1;
      End;
      filetime:=ord(dta[31]) shl 8 + ord(dta[30]);
      filedate:=ord(dta[33]) shl 8 + ord(dta[32]);
      Month := (FileDate shl 7) shr 12;
      Str(Month,S);
      OldVolumeNameDate := S + '-';
      Day := (FileDate shl 11) shr 11;
      If Day < 10 then OldVolumeNameDate := OldVolumeNameDate + '0';
      Str(Day,S);
      OldVolumeNameDate := OldVolumeNameDate + S + '-';
      Year := (FileDate shr 9) + 80;
      Str(Year,S);
      OldVolumeNameDate := OldVolumeNameDate + S + '  ';
      Hour := FileTime shr 11;
      If Hour >= 12 then begin
        AP := 'p';
        Hour := Hour - 12;
      End Else AP := 'a';
      If Hour = 0 then Hour := 12;
      Str(Hour:2,S);
      OldVolumeNameDate := OldVolumeNameDate + S + ':';
      Minute := (FileTime shl 5) shr 10;
      If Minute < 10 then OldVolumeNameDate := OldVolumeNameDate + '0';
      Str(Minute,S);
      OldVolumeNameDate := OldVolumeNameDate + S + AP;
    END;
    IF (HasLabel=False) or (AskChange) THEN Begin  {go on to change the label}
      Repeat
        Beep;
        GotoXY(30,10);ClrEol;
        ReadLn(labl);
        if (labl='') and (OldVolumeName<>'') then labl:=OldVolumeName;
        OldVolumeName:=labl;
      Until labl<>'';
      IF Length(labl) > 0 THEN BEGIN
        FOR i := 1 TO Length(labl) DO xfcb[7+i] := labl[i]; {insert label into xfcb}
        IF haslabel THEN BEGIN
          FOR i := 1 TO 11 DO dta[23+i] := xfcb[7+i]; {modify dta}
          regs.ds := Seg(dta[0]);
          regs.dx := Ofs(dta[0]);
          regs.ax := $1700;
          MsDos(regs);
        END ELSE BEGIN
          regs.ds := Seg(xfcb[0]);
          regs.dx := Ofs(xfcb[0]);
          regs.ax := $1600;
          MsDos(regs);
        END;
        GotoXY(1,11);ClrEol;
        IF Lo(regs.ax) = $FF THEN begin
          Boop;
          Write('Error in modifying label... press any key.');
          Read(Kbd,Ch);
        End ELSE Write(labl,' successfully created.');
      END;
    End;
  END; {volume}

OVERLAY PROCEDURE TestIt;
  VAR I,R,N,MatchCount : Integer;
      S1,S2,S3 : String[14];
      K,K2 : String[6];
  Begin
    SaveScreen;
    PrintCount:=0;
    ClrScr;
    If not PrTest then Repeat
      Beep;
      DrawBox(10,70,16,21);
      BigWindow(11,17,69,20);
      If MonitorType = 7 then begin
        HideCursor;
        For I:=1 to 4 do begin
          GotoXY(1,I);
          Write(ConstStr(' ',59));
        End;
        RestoreCursor;
      End Else ClrScr;
      HideCursor;
      GotoXY(5,2); WriteLn('Printer does not appear to be ready');
      GotoXY(5,3); WriteLn('Press any key when ready or ESC to return to menu');
      Repeat until KeyPressed;
      Read(Kbd,Ch);
      BigWindow(1,1,80,25);
      ClrScr;
      HideCursor;
      If (Ch = #27) and KeyPressed then Read(Kbd,Ch);
      If Ch = #27 then begin
        RestoreScreen;
        Exit;
      End;
    Until PrTest;
    OpenFiles;
    MatchCount:=0;
    For I:=1 to EntryNum do begin
      S1:=Entry[I].EName+Entry[I].EExt;
      WriteLn('Checking ',Entry[I].EName,'.',Entry[I].EExt);
      FKey:=S1;
      ClearKey(CIndex);
      SearchKey(CIndex,R,FKey);
      If OK then Repeat
        S2:=Copy(FKey,1,11);
        If S1=S2 then Begin
          MatchCount:=MatchCount+1;
          If PrintCount=0 then Begin
            WriteLn(Lst,'Listing of duplicate file NAMES found on ',SourceDirectory);
            WriteLn(Lst,ConstStr('-',79));
            WriteLn(Lst);
            PrintCount:=3;
          End;
          GetRec(CFile,R,FileRec);
          S3:=FileRec.FileName;
          Write(Lst,S3,' exists on disk ');
          Write(Lst,FileRec.VolPath,' with same name');
          If (Entry[I].EDate=FileRec.FileDate) and
             (Entry[I].ESize[1]=FileRec.FileSize[1]) and
             (Entry[I].ESize[2]=FileRec.FileSize[2]) and
             (Entry[I].ESize[3]=FileRec.FileSize[3]) and
             (Entry[I].ESize[4]=FileRec.FileSize[4]) then
             WriteLn(Lst,', size and date')
          Else WriteLn(Lst);
          PrintCount:=PrintCount+1;
          If PrintCount >=55 then begin
            Write(Lst,#12);
            PrintCount:=0;
          End;
        End;
        NextKey(CIndex,R,FKey);
        S2:=Copy(FKey,1,11);
      Until S1<>S2;
    End;
    ClrScr;
    GotoXY(30,10);
    Beep;
    WriteLn(MatchCount,' matches found.');
    If MatchCount>0 then begin
      WriteLn(Lst);
      WriteLn(Lst,MatchCount,' matches found.');
      MatchCount:=0;
    End;
    If PrintCount>0 then Write(Lst,#12);
    PrintCount:=0;
    GotoXY(8,12);
    Write('Do you also wish to check for possible Date/Size duplicates?  Y/N');
    If Yes then begin
      ClrScr;
      CloseIndex(CIndex);
      If NOT (Exist('FILECAT.TMP')) then begin
        Write('Please wait... building new index:');
        MakeIndex(CIndex,'FILECAT.TMP',6,1);
        HideCursor;
        For N := 1 to FileLen(CFile)-1 do begin
          GetRec(CFile,N,FTemp);
          If FTemp.Status=0 then begin
            GotoXY(37,WhereY);ClrEol;
            Write(N);
            K:='      ';
            For I:= 1 to 4 do K[I]:=Chr(Ord(FTemp.FileSize[I]));
            K[5]:=Chr(Hi(FTemp.FileDate));
            K[6]:=Chr(Lo(FTemp.FileDate));
            AddKey(CIndex,N,K);
          End;
        End;
        RestoreCursor;
        WriteLn;
      End Else OpenIndex(CIndex,'FILECAT.TMP',6,1);
      For I:=1 to EntryNum do begin
        K2:='      ';
        For R:= 1 to 4 do K2[R]:=Chr(Ord(Entry[I].ESize[R]));
        K2[5]:=Chr(Hi(Entry[I].EDate));
        K2[6]:=Chr(Lo(Entry[I].EDate));
        WriteLn('Checking ',Entry[I].EName,'.',Entry[I].EExt);
        FKey:=K2;
        ClearKey(CIndex);
        FindKey(CIndex,R,K2);
        If OK then Begin
          MatchCount:=MatchCount+1;
          If PrintCount=0 then Begin
            WriteLn(Lst,'Listing of duplicate file SIZE/DATEs found on ',SourceDirectory);
            WriteLn(Lst,ConstStr('-',79));
            WriteLn(Lst);
            PrintCount:=3;
          End;
          GetRec(CFile,R,FTemp);
          Write(Lst,Entry[I].EName,'.',Entry[I].EExt);
          Write(Lst,' has same date and size as ',FTemp.FileName);
          WriteLn(Lst,' on disk ',FTemp.VolPath);
          PrintCount:=PrintCount+1;
          If PrintCount >=55 then begin
            Write(Lst,#12);
            PrintCount:=0;
          End;
          Repeat
            NextKey(CIndex,R,K2);
            If (FKey=K2) and OK then begin
              MatchCount:=MatchCount+1;
              If PrintCount=0 then Begin
                WriteLn(Lst,'Duplicate file SIZE/DATEs found on ',SourceDirectory,' on ',TDate);
                WriteLn(Lst,ConstStr('-',79));
                WriteLn(Lst);
                PrintCount:=3;
              End;
              GetRec(CFile,R,FTemp);
              Write(Lst,Entry[I].EName,'.',Entry[I].EExt);
              Write(Lst,' has same date and size as ',FTemp.FileName);
              WriteLn(Lst,' on disk ',FTemp.VolPath);
              PrintCount:=PrintCount+1;
              If PrintCount >=55 then begin
                Write(Lst,#12);
                PrintCount:=0;
              End;
            End;
          Until (K2<>FKey) or (NOT OK);
        End;
      End;
      If MatchCount>0 then begin
        WriteLn(Lst);
        WriteLn(Lst,MatchCount,' matches found.');
        MatchCount:=0;
      End;
      If PrintCount>0 then Write(Lst,#12);
    End;
    PrintCount:=0;
    RestoreScreen;
    RestoreCursor;
    CloseFiles;
  End; { procedure TestIt }

OVERLAY PROCEDURE TestIt2;
  VAR I,R,N,MatchCount : Integer;
      S1,S2,S3 : String[14];
      K,K2 : String[6];
  Begin
    SaveScreen;
    PrintCount:=0;
    ClrScr;
    If not PrTest then Repeat
      Beep;
      DrawBox(10,70,16,21);
      BigWindow(11,17,69,20);
      If MonitorType = 7 then begin
        HideCursor;
        For I:=1 to 4 do begin
          GotoXY(1,I);
          Write(ConstStr(' ',59));
        End;
        RestoreCursor;
      End Else ClrScr;
      HideCursor;
      GotoXY(5,2); WriteLn('Printer does not appear to be ready');
      GotoXY(5,3); WriteLn('Press any key when ready or ESC to return to menu');
      Repeat until KeyPressed;
      Read(Kbd,Ch);
      BigWindow(1,1,80,25);
      ClrScr;
      HideCursor;
      If (Ch = #27) and KeyPressed then Read(Kbd,Ch);
      If Ch = #27 then begin
        RestoreScreen;
        Exit;
      End;
    Until PrTest;
    OpenFiles;
    MatchCount:=0;
    FKey:='';
    ClearKey(CIndex);
    SearchKey(CIndex,R,FKey);
    N:=R;
    S1:=Copy(FKey,1,11);
    While OK do begin
      WriteLn('Checking ',S1);
      NextKey(CIndex,R,FKey);
      S2:=Copy(FKey,1,11);
      If (S1=S2) and OK then Begin
        GetRec(CFile,N,FTemp);
        GetRec(CFile,R,FileRec);
        MatchCount:=MatchCount+1;
        If PrintCount=0 then Begin
          WriteLn(Lst,'Listing of duplicate file NAMES found in FILECAT database on ',TDate);
          WriteLn(Lst,ConstStr('-',79));
          WriteLn(Lst);
          PrintCount:=3;
        End;
        Write(Lst,FTemp.FileName,' on ',FTemp.VolPath,' same as ');
        WriteLn(Lst,FileRec.FileName,' on ',FileRec.VolPath);
        PrintCount:=PrintCount+1;
        If PrintCount >=55 then begin
          Write(Lst,#12);
          PrintCount:=0;
        End;
      End;
      S1:=S2;
      N:=R;
    End;;
    ClrScr;
    GotoXY(22,10);
    Beep;
    WriteLn(MatchCount,' matches found... press any key.');
    Read(Kbd,Ch);
    If MatchCount>0 then begin
      WriteLn(Lst);
      WriteLn(Lst,MatchCount,' matches found.');
      MatchCount:=0;
    End;
    If PrintCount>0 then Write(Lst,#12);
    PrintCount:=0;
    RestoreCursor;
    RestoreScreen;
    CloseFiles;
  End; { procedure TestIt2 }

OVERLAY PROCEDURE InitializeFiles;
  VAR I:Integer;
  Begin
    ChDir(EntryDirectory);
    OpenFile(CFile,'FILECAT.DAT',SizeOf(FRec));
    If OK then OpenIndex(CIndex,'FILECAT.IXN',14,1);
    If NOT OK then begin
      Beep;
      GotoXY(5,25);
      Write('Files not found.  Creating new files.');
      MakeFile(CFile,'FILECAT.DAT',SizeOf(FRec));
      MakeIndex(CIndex,'FILECAT.IXN',14,1);
    End;
    CloseFile(CFile);
    CloseIndex(CIndex);
    OpenIndex(KIndex,'FILECAT.KWD',15,0);
    If NOT OK then MakeIndex(KIndex,'FILECAT.KWD',15,0);
    CloseIndex(KIndex);
    GotoXY(1,25);ClrEol;
    InitFiles:=True;
  End; { procedure InitializeFiles }

OVERLAY PROCEDURE Goodbye;
  Begin
    GotoXY(1,1);
    WriteLn('Thank you for using FILECAT');
    WriteLn;
    WriteLn('PLEASE back up your data disk on a regular basis...');
    WriteLn('It will just take a couple of minutes, and will help prevent disaster.');
    WriteLn;
    WriteLn('Floppy Disk Users: Put your working data disk in A, backup disk in B.');
    WriteLn('                   Type "COPY A:*.* B:" and return.');
    WriteLn;
    WriteLn('  Hard Disk Users: Change into your FILECAT subdirectory.');
    WriteLn('                   Put your backup disk in drive A.');
    WriteLn('                   Type "COPY *.*  A:"');
    WriteLn;
    WriteLn('Enjoy... Kenn Flee');
  End; { procedure Goodbye }
