unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, nexcel;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  f1, f2:textfile;
  cesta:string;
  znak:char;
  pocitadlo_carek, pocitadlo_znaku:longword;
  Book: IXLSWorkbook;
  ws: IXLSWorksheet;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
cesta:=getcurrentdir;
pocitadlo_carek:=0;
pocitadlo_znaku:=0;

if fileexists (cesta+'\curve.txt') then begin
                                          assignfile (f1, cesta+'\curve.txt');
                                          reset (f1);
                                          assignfile (f2, cesta+'\curve-out.txt');
                                          rewrite (f2);
                                          closefile (f2);
                                          assignfile (f2, cesta+'\curve-out.txt');

                                          repeat
                                            read (f1, znak);
                                            if znak<>',' then begin
                                                                append (f2);
                                                                write(f2, znak);
                                                                closefile (f2);
                                                                inc (pocitadlo_znaku);
                                                              end
                                                         else begin
                                                                inc (pocitadlo_carek);
                                                                if pocitadlo_carek = 988 then begin
                                                                                                pocitadlo_carek:=pocitadlo_carek;
                                                                                              end;

                                                                form1.caption:='Počet čárek: '+ inttostr (pocitadlo_carek);
                                                                append (f2);
                                                                write (f2, chr(13));
                                                                write (f2, chr(10));
                                                                closefile (f2);
                                                              end;       

                                          until eof (f1);
                                          MessageDlg('Hotovo!!' + chr(10)+'Počet čárek: '+inttostr (pocitadlo_carek)+chr(10)+'Počet znaků: '+inttostr (pocitadlo_znaku), mtConfirmation, [mbYes], 0);
                                          halt (0);
                                          closefile (f1);

                                        end
                                   else begin
                                          MessageDlg('Nenalezen vstupní soubor, aplikace bude ukončena!!', mtConfirmation, [mbYes], 0);
                                          halt (0);
                                        end;





end;

end.
