unit Sp2cma;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    {Private declarations}
  public
    {Public declarations}
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

var
 Fname: String;

procedure TForm1.Button1Click(Sender: TObject);
begin
 OpenDialog1.FileName := '*.*';
 if OpenDialog1.Execute then
 begin
  Fname := OpenDialog1.FileName;  {nazwa pliku}
  Edit1.Text := Fname;   {wywietlamy nazw pliku}
  Edit1.Visible := True;
  Label1.Visible := True;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 InFile: File;
 FBuffer: array[1..1024] of Byte;
 FPointer: Longint;
 BytesRead: Integer;
 x: Integer;
begin
 AssignFile(InFile, Fname);  {inicjacja zmiennej plikowej}
 Reset(InFile, 1); {ustalamy rozmiar rekordu na 1 bajt}
 while not Eof(InFile) do
 begin
   FPointer := FilePos(InFile); {pozycja pliku}
   {odczytujemy z pliku 1 KB danych}
   BlockRead(InFile, FBuffer, SizeOf(FBuffer), BytesRead);
     for x := 0 to BytesRead - 1 do {ptla zamiany}
     begin
      if FBuffer[x] = 32 then FBuffer[x] := 44;
     end;
   Seek(InFile, FPointer);  {wracamy na pocztek bloku}
   {zapisujemy poprawiony blok}
   BlockWrite(InFile, FBuffer, BytesRead);
 end;
 CloseFile(InFile);
 ShowMessage('Processing Complete!');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 Application.Terminate;
end;

end.