program Emulator_Copy_Utilite;
{$I-,S-}
{$M 8192,8192,655360}
uses Dos,Crt;


{-----------------------------VARIABLES & SETTINGS---------------------------}
const
  MaxDirSize = 517;
  AnyType = '*.*';
type
  DirPtr   = ^DirRec;         { 뫪  pointer DirRec   }
  DirRec   = record           { ⥫  䠩         }
               Attr: Byte;
               Time: Longint;
               Size: Longint;
               Name: string[12];
             end;
  DirList  = array[0..MaxDirSize - 1] of DirPtr;

  Restore  = record          { ࠭  䠩    室  }
               cur_bak:byte; {  ४਩                           }
               fil_bak:word;
             end;
  Back_Up  = array [1 .. 64] of Restore;

var
  MainFileName                         :string;
  TabFileName                          :string;
  CopyFile                             :string[8];
  Xtv,Xpoz,Hl,Ll,peek,CurrentSet,HowManyFiles:byte;
  MainFile                             :file of byte;
  NewFIle                              :file of byte;
  FileLen,FileSec,LoadPlace            :word;
  Track,Secktor                        :LongInt;
  Done,Error,SaveOk,Escape             :boolean;
  FileType                             :char;
  HowReal                              :real;


  cursor,Windows_x,Windows_y,Windows_l :byte;
  FirstFile,InDir                      :word;
  Count                                :integer;
  dir_message                          :string[40];
  N                                    :NameStr;
  E                                    :ExtStr;
  Path                                 :PathStr;
  Dir                                  :DirList;
  Back                                 :Back_up;
  Sz,Place,FreeSectors,FreeSpace       :longint;

  key1,key2                            :char;
  Spectrum                             :boolean;


{--------------------------- 騥 e --------------------------------}
Procedure Clear_Place(xx,yy,len:byte);
var loop:byte;
begin
 for loop:=yy to yy+len do
  begin
   GotoXY(xx,yy);
   Write('                  ');
   Inc(yy);
  end;
end;
{------------------------------ Out Messages --------------------------------}
Procedure Message(TextPrn:string);          { 뢮 室 ⥪}
begin
 GotoXY(9,24);
 ClrEol;
 GotoXY(9,24);
 Textcolor(red);
 Write(TextPrn);
end;
{----------------------------- Scan Key Routine -----------------------------}
Procedure ScanKey;
begin
 key1:=#255;
 key2:=#255;
  while not keypressed do begin end;
   key1:= ReadKey;
   Case key1 of
    #0 : key2:=readkey;
    #27: begin
          TextColor(7);
          ClrScr;
          WriteLn('1996-1997 RIP Group (C)  -->Klondike');
          WriteLn('v1.0 Alfa, sorry if something wrong.');
          halt(1);
         end;
   end;
end;
{--------------------------뢮 p  -----------------------------}
Procedure Print_Window(xx,yy,wh,ln:byte);
var loop:byte;
begin
  TextColor(3);
  for loop := xx to xx+ln do
   begin
    GotoXY(loop,yy   );Write('');
    GotoXY(loop,yy+wh);Write('');
   end;
    for loop := yy to yy+wh do
     begin
      GotoXY(xx-1,loop );Write('');
      GotoXY(xx+ln,loop);Write('');
     end;
  GotoXY (xx-1,yy    );Write('',#213);
  GotoXY (xx+ln,yy   );Write(#184);
  GotoXY (xx-1,yy+wh );Write('',#212);
  GotoXY (xx+ln,yy+wh);Write(#190);
  TextColor(7);
end;
{------------------------------ Title Screen --------------------------------}
Procedure Title;
 begin
  Clrscr;
  GotoXY(1,24);
  TextColor(7);
  WriteLn('Status:');
  TextBackground(3);
  TextColor(0);
  GotoXY(1,1);
  Write('     This stuff done by Klondike of Real Imagines Progs 1996(C)       *Alfa*    ');
  TextBackground(0);
  TextColor(7);
  GotoXY(31,3);
  Write('TR-DOS in file Catalogue            Tree:');
  TextColor(3);
  Print_Window(28,4,17,29);
end;
{-------------------------뢮 p業⭮ ⥫-----------------------}
Procedure Show_The_Dog(xx,yy,len:byte; all,now:real);
var  loop,dog:byte;
begin
 TextColor(3);
 for loop:=yy to yy+len do
  begin
   GotoXY(xx,loop);
   Write('');
  end;
   if all<>0 then
    begin
     dog:=Trunc(now/(all/len));
     GotoXY(xx,yy+dog);
     Write('');
     TextColor(7);
    end;
end;



{----------------------------- MS Dos Procedures-----------------------------}
{-------------------------- ⠢ A,B,C,D,E:\ -----------------------------}
Procedure Insert_drives;
var
    driv:SearchRec;
begin
 FindFirst(Path, ReadOnly + Directory + Archive, driv);
 driv.Name:='A:\';
 driv.Attr:=69;
 for Count:=0 to 4 do
  begin
     GetMem(Dir[Count], Length(driv.Name)+10);
     Move(driv.Attr,Dir[Count]^, Length(driv.Name)+10);
     Inc(driv.Name[1]);
  end;
end;
{---------------------------ᥭ pp  ᨢ--------------------}
procedure FindFiles;
var
  F: SearchRec;
begin
  Count := 5;
  FindFirst(Path, ReadOnly + Directory + Archive, F); {頥 pp  䠩   SearchRec                }
   If DosError <> 0 then
    begin
     Message('System Error: ');
     Write(DosError);
     halt(1);
    end;
  while (DosError = 0) and (Count < MaxDirSize) do
   begin
    GetMem(Dir[Count], Length(F.Name) + 10);          {뤥     p Dir[count] pp F.Name+10      }
    Move(F.Attr, Dir[Count]^, Length(F.Name) + 10);   {p  p F  Name  p Dir[count] F.Name+10 }
    Inc(Count);
    FindNext(F);
   end;
end;
{----------------------  䠩  p I------------------------}
Procedure Get_File_Name(I:integer);
var
  P: Integer;
begin
 with Dir[I]^ do
  begin
   P := Pos('.', Name);          {P = p  p⥫ '.'    䠩}
    if P > 1 then                {᫨ P<>0   䠩   pp               }
     begin
      N := Copy(Name, 1, P - 1); {᪮p  N  䠩  < 窨>         }
      E := Copy(Name, P + 1, 3); {᪮p  P pp  3                 }
      Sz:=Size;
     end
      else
     begin
      N := Name;                 { N= pp, E=''                        }
      E := '';
     end;
     Write(N, ' ': 9 - Length(N), E, ' ': 4 - Length(E));
     if Attr=69 then Write('Drive')
      else
       if Attr and Directory <> 0 then Write('<DIR>')
        else
         begin
          if E<>'TRD' then Write('     ')
           else Write ('  ',#251,'  ');
         end;
  end;
end;
{---------------------------- ᥣ ᨢ----------------------------}
procedure PrintFiles(W_Xup,W_Yup,W_Len:byte; W_cou:word);
var
 last:word;
 I:Integer;
begin
  If Count-1<W_Len then last:=Count-1+W_cou else last:=W_Len+W_cou;
   for I := W_cou to last do
    begin
     GotoXY(W_Xup,W_Yup);
     Get_File_Name(I);
     Inc(W_Yup);
    end;
  GotoXY(31,22);
  dir_message:=Copy(path,1,40);
  Write('Path ', dir_message);
  ClrEol;
end;

{-------------------- p楤p窠 p  Ms-Dos -------------------}
Procedure Copy_From_MSDOS;
var loads,loadt:byte;
    loop,free:longint;
    sreal,treal:longint;
    Ftype,UseSectors:byte;

Procedure Insert_Header;
var loop:byte;
begin;
 Seek(MainFile,Free);
 if Length(N)<8 then for loop:=Length(N)+1 to 8 do N[loop]:=' ';

 for loop:=1 to 8 do
  begin
   peek:=ord(N[loop]);
   Write(MainFile,peek);
  end;
 Write(MainFile,Ftype);
 peek:=0;
 Write(MainFile,peek);
 Write(MainFile,peek);
 Hl:=0;
 Ll:=0;
  if Sz<65535 then
   begin
    Hl:=Trunc(Sz/256);
    Ll:=Sz-256*Hl;
   end;
 Write(MainFile,Ll);
 Write(MainFile,Hl);
   if Ll<>0 then inc(Hl);
 UseSectors:=Hl;
 Write(MainFile,Hl);
 Write(MainFile,Loads);
 Write(MainFile,Loadt);

{-------------------- ८ଫ 0' ४ -----------------}
 Seek(MainFile,256*8+225);       {  ᢮ ᥪ/४ }
 Read(Mainfile,peek);
 Read(MainFile,Ll);
  while Hl>16 do
   begin
    inc(Ll);
    Hl:=Hl-16;
   end;
 peek:=peek+Hl;
  if peek>16 then
   begin
    peek:=peek-16;
    Ll:=Ll+1;
   end;
 Seek(MainFile,256*8+225);       {  ᢮ ᥪ/४ }
 Write(MainFile,peek);
 Write(MainFile,Ll);

 Seek(MainFile,256*8+229);       { ⢮ ᢮ ᥪ஢ }
 FreeSectors:=FreeSectors-UseSectors;
 Hl:=trunc(FreeSectors/256);
 Ll:=FreeSectors-256*Hl;
 Write(Mainfile,Ll);
 Write(MainFile,Hl);

 Seek(MainFile,256*8+228);
 Read(MainFile,peek);            { ⢮ 䠩  ᪥ }
 Inc(peek);
 Seek(MainFile,256*8+228);
 Write(MainFile,peek);
end;
                                                {-------------}
begin
 {$i-}
 Reset (MainFile);
 {$i+}
  if IOresult<>0 then
   begin
    Message ('Sorry, there are is bug Nr1 finded. Press any key for get out to DOS.');
    ScanKey;
    halt(1);
   end;
  Seek(MainFile,256*8+228);
  Read(MainFile,peek);           { ⢮ 䠩  ᪥ }
  Free:=16*peek;
   if peek>127 then
    begin
     Message('No free space in Dir !');
     ScanKey;
     exit;
    end;
  Seek(MainFile,256*8+229);     { ⢮ ᢮ ᥪp }
  Read(MainFile,Ll);
  Read(MainFile,Hl);
  sreal:=Ll;
  treal:=Hl;
  FreeSectors:=sreal+256*treal;
  FreeSpace:=FreeSectors*256;
   if FreeSpace<Sz then
    begin
     Message('No free space !');
     Scankey;
     exit;
    end;

  Ftype:=ord('C');
   if Sz>65535 then
     begin
      Ftype:=ord('L');
      Message('Copyed LONG file! Attr - /L');
     end
    else
      Message('Copyed file. Attr - /C');

  Seek(MainFile,256*8+225);
  Read(MainFile,loads);
  Read(MainFile,loadt);
  sreal:=loads;
  treal:=loadt;
  Place:=256*sreal+4096*treal;

  Insert_Header;

  dir_message:=Copy(Path,1,(Length(Path)-3));
  dir_message:=dir_message+N+'.'+E;
  Assign(NewFile,dir_message);
  {$i-}
  Reset (NewFile);
  {$i+}
   if IOresult<>0 then
    begin
     Message ('Sorry ,there are is bug Nr2 finded. Press any key for get out to DOS.');
     ScanKey;
     halt(1);
    end;

 Seek(MainFile,Place);
 for loop:=1 to Sz do
  begin
   Read (NewFile,peek);
   Write(MainFile,peek);
  end;
 Close(NewFile);
end;
{----------------------p楄p p饭  ⠫---------------------}
Procedure Select_File;
Procedure Show_cursor;
begin
 GotoXY(Windows_x,cursor+Windows_y);
 Get_File_Name(FirstFile+cursor);
end;

begin
 Done:=false;
 repeat
   TextColor(30);
   GotoXY(Windows_x,cursor+Windows_y);
   Get_File_Name(FirstFile+cursor);
   Show_The_Dog(Windows_x-2,Windows_y,Windows_l,count-1,FirstFile+Cursor);
   Message('Select file to open or copy in CAT-file ... ');
   TextColor(7);
   ScanKey;
    if key1=#09 then
     if Spectrum then
      begin
       MainFileName:=TabFileName;
       done:=true;
       exit;
      end;
    Case key2 of
     #63: begin
           With Dir[FirstFile+cursor]^ do
            begin
             If attr and directory = 0 then
               if spectrum then Copy_From_MSDOS;                        {***F5***}
            end;
          end;
     #71: begin    {Home}
           Show_cursor;
           cursor:=0;
           FirstFile:=0;
           PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
          end;
     #79: begin    {End}
           Show_cursor;
           cursor:=0;
            if Count-1>Windows_l then
             begin
              cursor:=Windows_l;
              FirstFile:=Count-1-Windows_l;
              PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
             end
            else
             if Count<>0 then cursor:=Count-1;
          end;
     #81: begin    {PgDw}
           Show_cursor;
           if Count-1>Windows_l then
            begin
             if Count-1-(FirstFile+Windows_l)>Windows_l then Firstfile:=FirstFile+Windows_l
              else
               begin
                FirstFile:=Count-1-Windows_l;
                cursor:=Windows_l;
               end;
             PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
            end
             else if Count<>0 then cursor:=Count-1;
          end;
     #73: begin    {PgUp}
           Show_cursor;
           if FirstFile>0 then
            begin
             if FirstFile>Windows_l then FirstFile:=FirstFile-Windows_l
              else
               begin
                FirstFile:=0;
                cursor:=0;
               end;
             PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
            end
             else cursor:=0;
          end;
     #72: begin    {UP}
           if cursor>0 then
            begin
             Show_cursor;
             Dec(cursor);
            end
           else
            begin
             if FirstFile>0 then
              begin
               Dec(FirstFile);
               PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
              end;
            end;
          end;
     #80: begin      {DOWN}
           if cursor<Windows_l then
            begin
             if cursor<Count-1 then
              begin
               Show_cursor;
               Inc(cursor);
              end
            end
           else
            begin
             if FirstFile+Windows_l<Count-1 then
              begin
               Inc(FirstFile);
               PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
              end;
            end;
          end;
    end; {of case}
 until key1=#13
end;
{-------------p-p p⪨ ⢨  Enter  pp------------}
Procedure Do_dir;
var loop,copy1:byte;
    select:boolean;
begin
 while 0=0 do
  begin
   FindFiles;
   Clear_Place(Windows_x,Windows_y,Windows_l);
   PrintFiles(Windows_x,Windows_y,Windows_l,FirstFile);
   Select_file;
   If done then exit;
    With Dir[FirstFile+cursor]^ do
     begin
      If attr and directory <> 0 then
       begin
        If N='..' then   {  ।騩}
         begin
          Dec(InDir);
          with back[InDir] do
           begin
            cursor   :=cur_bak;
            FirstFile:=fil_bak;
           end;
          loop:= Length(Path);
          repeat Dec(loop) until Path[loop]='\';
           copy1:=loop;
          repeat Dec(loop) until Path[loop]='\';
          Delete(Path,loop,copy1-loop);
         end;
        If N='.' then    { ୥}
         begin
          cursor:=0;
          InDir:=1;
          for loop:=4 to Length(Path) do Path[loop]:=' ';
          Insert(AnyType,Path,4);
         end;
        If N[1]<>'.' then
         begin
          with back[InDir] do
           begin
            cur_bak:=cursor;
            fil_bak:=FirstFile;
           end;
          Inc(InDir);
           if Windows_l>5 then cursor:=6
            else cursor:=Windows_l;
          FirstFile:=0;
          loop:= Length(Path);
          while Path[loop]<>'\' do Dec(loop);
          Inc(loop);
          Insert(N,Path,loop);
          Insert('\',Path,loop+length(N));
         end;
       end
        else
         if attr = 69 then
           begin
            FirstFile:=0;
            path:=name+AnyType;
            InDir:=1;
           end
          else
           begin
            MainFileName:=Path;
            Delete(MainFileName,Length(MainFileName)-2,3);
            MainFileName:=MainFileName+Name;
            exit;
           end;

     end;
  end;
end;

{------------------------------ MS Dos Main ---------------------------------}
Procedure Work_With_MsDos;
begin
  FirstFile:=0;
  Print_Window(Windows_x-1,Windows_y-1,Windows_l+2,19);
  Do_Dir;
end;




{----------------------------- TR Dos Procedures ----------------------------}
Procedure AssignFile;
begin
 Done :=false;
 Error:=false;
 Assign(MainFile,MainFileName);
 {$i-}
 Reset (MainFile);
 {$i+}
  if IOresult<>0 then
    begin
     error:=true;
     exit;
    end;
  if FileSize(MainFile)<>655360 then
   begin
    Close(MainFile);
    exit;                                 {not tr-dos file-cat}
   end;
  Seek(Mainfile,256*8+231);
  Read(MainFile,peek);
   If peek<>16 then
    begin
     Close(MainFile);
     exit;                                 {not tr-dos file-cat}
    end;
  TextColor(7);
  Seek(MainFile,(256*8+228));
  Read(mainfile,HowManyFiles);
  HowReal:=HowManyFiles;
  Done:=true;
  Clear_Place(30,5,15);
  Clear_Place(38,5,15);
end;



Procedure MakeHeader(Ink:byte);             { ନ஢    }
var i:byte;
 begin
  if HowManyFiles=0 then
   begin
    Write('  No files in directory');
    exit;
   end;
  TextColor(Ink);
  If peek=1 then peek:=Ord('~');
  CopyFile[1]:=Chr(peek);
   for i:=2 to 8 do
    begin
     Read(MainFile,peek);               {        }
     CopyFile[i]:=Chr(peek);
    end;
      Read(MainFile,peek);              {  ७ }
      FileType:=Chr(peek);

      Read(MainFile,Ll);                {  㧮  䠩.  }
      Read(MainFile,Hl);                {                            }
      LoadPlace:=Ll+256*Hl;             {                            }

      Read(MainFile,Ll);                {     (㦭)  }
      Read(MainFile,Hl);
      FileLen:=Ll+256*Hl;               {                            }
      Write(CopyFile,'  ',FileType,'               ');

      Read(MainFile,Ll);                {   ( ᥪ)        }
      FileSec:=Ll*256;                  {                            }
      GotoXY(43,Xpoz);
      Write(LoadPlace);
      GotoXY(49,Xpoz);
      Write(', ',FileLen);

      Read(MainFile,peek);
      Secktor:=peek;
      Read(MainFile,peek);
      Track:=peek;
end;


Procedure OutParameters(ink:byte);          { ନ஢  뤠   }
var time:byte;                              {   ⥪饣  }
 begin                                      { 䠩                   }
  Seek(MainFile,(CurrentSet+Xtv-5)*16);
  Read(MainFile,peek);
  time:=Xpoz;
  Xpoz:=Xtv;
  GotoXY(30,Xpoz);
  MakeHeader(ink);
  TextColor(2);
  GotoXY(3,6);
  WriteLn('---- File Header ----');
  WriteLn;
  WriteLn('     Name :',CopyFile,'       ');
  WriteLn('     Type :',FileType);
  WriteLn('     Adr  :',LoadPlace,'     ');
  WriteLn('     Bytes:',FileLen,'     ');
  WriteLn('     Real :',FileSec,'     ');
  WriteLn;
  WriteLn('  ---- Disk  Place ----');
  WriteLn;
  WriteLn('     Sec  :',Secktor,' ');
  WriteLn('     Trk  :',Track,' ');
  WriteLn('     Ofset:',(track*4096+secktor*256),'    ');
  Xpoz:=time;
  TextColor(4);
  Message('Select File');
end;


Procedure RenameFile;
var NName:string[8];                       { २ ⥪饣 䠩 }
    i:byte;
begin
 Message('Input new FileName ...');
 NName:='        ';
 i:=1;
 key1:=#0;
  repeat
   GotoXY(30,Xtv);
   Write(NName);
   GotoXY(29+i,Xtv);
   Write('');
   key1:=readkey;
    Case key1 of
          #27: exit;
          #8 : begin
                NName[i]:=' ';
                if i>1 then dec(i);
               end;
     ' '..'z': begin
                NName[i]:=key1;
                 if i<8 then inc(i);
                Write (key1);
               end;
    end;
  until key1=#13;
  Seek(MainFile,(CurrentSet+Xtv-5)*16);
   for i:=1 to 8 do
    begin
     peek:=Ord(NName[i]);
     Write(MainFile,peek);
    end;
  key1:=#0;
end;



Procedure OneScreenPrint;    { ⨭  ࠭ ⠫ }
 begin
  Xpoz:=5;
   Seek(MainFile,(CurrentSet*16));
   while xpoz<>21 do
    begin
      GotoXY(30,Xpoz);
      Read(MainFile,peek);
       If peek=0 then exit;
      MakeHeader(6);
      Inc (Xpoz);
    end;
end;

Procedure SetMarker;
var i:byte;
  step,dog:integer;
begin
  if HowManyFiles=0 then exit;
  TextColor(2);
  GotoXY(29,Xtv);Write('');
  GotoXY(56,Xtv);Write('');
  Show_The_Dog(27,5,15,HowManyFiles,CurrentSet+(Xtv-5));
end;

Procedure ResMarker;
begin
  GotoXY(29,Xtv);Write(' ');
  GotoXY(56,Xtv);Write(' ');
end;


Procedure CopyVirtyalFile;
var
   i:word;
begin
  SaveOk:=false;
  OutParameters(2);
  Assign(NewFile,CopyFile+'.spc');

 {$i-}
   Reset(NewFile);
 {$i+}
    If IOresult=0 then
      begin
       Close(NewFile);
       Message('File exist!');
       ScanKey;
       exit;
     end;

 {$i-}
   Rewrite(NewFile);
 {$i+}
    If IOresult<>0 then
      begin
       Message('Cant open file!');
       ScanKey;
       Exit;
      end;

   Message('Copy in progress...');
   Seek(MainFile,(track*4096+secktor*256));
   for i:=1 to FileSec do
    begin
      Read (MainFile,peek);
      Write(NewFile,peek);
    end;
   Message('Done...');
   SaveOk:=true;
   ScanKey;
   Exit;
end;



Procedure SelectFile;
begin
 OneScreenPrint;
 SetMarker;
  While not done do
   begin
    OutParameters(2); {}
    Scankey;
    if HowManyFiles<>0 then
     begin
      Case key2 of
       #72: begin                   { UP }
             if Xtv=5 then
              begin
               if CurrentSet<>0 then
                 begin
                   Dec(CurrentSet);
                   OneScreenPrint;
                   SetMarker;
                end
              end
             else
               begin
               OutParameters(6);
               ResMarker;
               Xtv:=Xtv-1;
               SetMarker;
               OutParameters(2);{}
               end;
            end;

       #80: begin                     { Down }
            if (Xtv-5)+CurrentSet+1<>HowManyFiles then
             begin
              if Xtv=20 then
               begin
                if CurrentSet<>(HowManyFiles-16) then
                 begin
                  Inc(CurrentSet);
                  OneScreenPrint;
                  SetMarker;
                 end
               end
              else
               begin
                OutParameters(6);
                ResMarker;
                Xtv:=Xtv+1;
                SetMarker;
                OutParameters(2);{}
               end;
             end;
            end;

       #79: begin                        { End }
              if HowManyFiles>16 then
               begin
                 CurrentSet:=HowManyFiles-16;
                 OneScreenPrint;
                 SetMarker;
               end;
             end;

       #71: begin                        { Home }
             CurrentSet:=0;
             OneScreenPrint;
             SetMarker;
            end;

       #82: begin                        { Insert }
             RenameFile;
             OutParameters(2);
            end;
      end;         {--------------------------CASE}
     end;

        CASE key1 of
          #09: begin           { Tab    }
               Escape:=true;
               ResMarker;
               OneScreenPrint;
               TabFileName:=MainFileName;
               Spectrum:=true;
               Close(MainFile);
               exit;
               end;

          #13: begin           { Enter  }
               CopyVirtyalFile;
               Exit;
               end;
        end;  {---------------------CASE}

    end;
end;

{------------------------------ TR DOS MAIN ---------------------------------}
Procedure Work_With_TrDos;
begin
 CopyFile:='FileName';
 Escape:=false;
 Xtv:=5;
 CurrentSet:=0;
 AssignFile;
  if Error then
   begin
    Message('System problems with opening file...');
    ScanKey;
    exit;
   end;
  if not Done then
   begin
    Message('Make ya sure: that is _NOT_ TrDos file-cat!');
    ScanKey;
    exit;
   end;
 While not Escape do
  begin
   done:=false;
   SelectFile;
    If SaveOk then
     begin
      Close(NewFile);
      SaveOk:=false;
     end;
  end;
end;

{----------------------------------- MAIN -----------------------------------}
begin
 Title;
 Path:='C:\'+AnyType;
 Insert_Drives;
 Windows_x:=61;
 Windows_y:=5;
 Windows_l:=15;
 cursor:=0;
 InDir:=1;
 Spectrum:=false;
  repeat
   Work_With_MsDos;
   Work_With_TrDos;
  until 1<>1;
end.