UNIT FileCopy;

INTERFACE

USES Crt,Dos,Graph;

CONST GraphikModus = 1;
      TextModus    = 2;
      OhneAnzeige  = 0;

Procedure FCopy( FrF,TofF : String;
                 Mode     : Shortint;
                 X,Y      : Integer   );

IMPLEMENTATION

Procedure FCopy( FrF,TofF : String;
                 Mode     : Shortint;
                 X,Y      : Integer   );

Const ConGra = 100; 
      ConTxt = 20;  

Var
  FromF, ToF            : File;
  i,k,j                 : Integer;
  NumRead, NumWritten   : Word;
  Buf                   : Array[1..10] Of Char; {NEVER EDIT !!!!!!!!!!!}
  Faktor                : Integer;
  Faktor2               : Real;
  FS                    : Longint;
  OrgFarbe              : Word;
  OldStyle              : LineSettingsType;
  FillInfo              : FillSettingsType;

Begin
  if FSEARCH(FrF,'') = '' then  exit;
  Assign (FromF, FrF);
  Reset  (FromF, 1);
  Assign (ToF, TofF);
  Rewrite(ToF, 1);
  i:=0;
  j:=0;
  FS      := FileSize(FromF);
  Faktor  := Fs div 10;

  Case Mode of
    GraphikModus:
    Begin
      Faktor2  := Faktor Div ConGra;
      OrgFarbe := GetColor;
      GetFillSettings(fillinfo);
      GetlineSettings(oldstyle);
      SetColor(15);
      SetFillStyle(emptyfill,0);
      SetLineStyle(SolidLn,0,ThickWidth);
      Rectangle(x-2, y-2, x+104,y+22);
      Repeat
        Inc(j);
        BlockRead(FromF,Buf,SizeOf(Buf),NumRead);
        BlockWrite(ToF,Buf,NumRead,NumWritten);
        If (j=Faktor2) and (i<>ConGra)then
         begin
         SetFillStyle(Solidfill,9);
         SetColor(9);
         Bar(x+i,y,x+1+i,y+20);
         Delay(10);
         i:=i+1;
         j:=0;
         end;
      until (NumRead = 0) or (NumWritten <> NumRead);
    End;

    TextModus:
    begin
      Faktor2 := Faktor Div ConTxt;
      GotoXY(x,y); TextColor(15); Write('[');
      GotoXY(x+21,y); Write(']');
      TextColor(9);
      repeat
        Inc(j);
        BlockRead(FromF,Buf,SizeOf(Buf),NumRead);
        BlockWrite(ToF,Buf,NumRead,NumWritten);
        If (j=Faktor2) and (i<>ConTxt) then
        begin
          i:=i+1;
          GotoXY(X+i,y); Write('þ');
          Delay(10);
          j:=0;
        end;
      until (NumRead = 0) or (NumWritten <> NumRead);
    End;

    OhneAnzeige:
    begin
     repeat
      BlockRead(FromF,Buf,SizeOf(Buf),NumRead);
      BlockWrite(ToF,Buf,NumRead,NumWritten);
     until (NumRead = 0) or (NumWritten <> NumRead);
    End;
  End;

  Close(FromF);
  Close(ToF);

  If Mode=GraphikModus then
  begin
    SetColor(OrgFarbe);
    With FillInfo Do SetFillStyle(Pattern, Color);
    With OldStyle Do SetLineStyle(LineStyle, Pattern, Thickness);
  end;
End;

BEGIN
  fcopy
END.
