below is your fixed code.
Unit Unit1;
{$mode objfpc}{$H+}
Interface
Uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
StdCtrls, FileCtrl;
Type
{ TForm1 }
TForm1 = Class(TForm)
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
FileListBox1: TFileListBox;
ProgressBar1: TProgressBar;
Procedure Button2Click(Sender: TObject);
Private
{ private declarations }
Public
{ public declarations }
End;
Var
Form1: TForm1;
Implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button2Click(Sender: TObject);
var
Str: TStringList;
PriceData: String;
i:Longint;
opened:boolean;
begin
opened:=true;
Str := TStringList.Create;
try
Str.LoadFromFile(FileListBox1.FileName);
//Str.LoadFromFile(UTF8ToSys(FileListBox1.FileName));
except
opened:=false;
Edit2.text:='Cannot open file';
end;
if opened then
begin
if FileListBox1.Items.Count -1 <> -1 then
begin
ProgressBar1.Min:=0;
ProgressBar1.Max:=Str.Count;
// ProgressBar1.Max:=FileListBox1.Items.Count;
ProgressBar1.Position:= progressbar1.Position + 1;
i:=0;
while i<Str.Count do
begin
Application.ProcessMessages;
PriceData:=Str[i];
Edit2.text:=PriceData;
progressbar1.Position:= progressbar1.Position + 1;
i:=i+1;
end;
Edit2.text:=inttostr(i);
end else
begin
Edit2.text:='File Empty';
end;
end;
Edit2.text:=inttostr(Str.Count);
Str.SaveToFile(FileListBox1.FileName);
Str.Free;
end;
End.