procedure TForm1.Button2Click(Sender: TObject);var Str: TStringList; Price: string; PriceStr: Packed Array[1..300] of char; cafl: array[0..1000] of Integer; ask,bid,freq,y: Real; code,ifreq,x: Integer; asc,i,j,timsec: LongInt; morech,opened:boolean;begin i:=0; while i<1000 do begin cafl[i]:=0; i:=i+1; end; Str.Free;end;
Commenting out the STR.Free statement stops the exception.
unit1.pas(48,3) Warning: Local variable "Str" does not seem to be initializedunit1.pas(34,3) Note: Local variable "Price" not usedunit1.pas(35,3) Note: Local variable "PriceStr" not usedunit1.pas(36,3) Note: Local variable "cafl" is assigned but never usedunit1.pas(37,3) Note: Local variable "ask" not usedunit1.pas(37,7) Note: Local variable "bid" not usedunit1.pas(37,11) Note: Local variable "freq" not usedunit1.pas(37,16) Note: Local variable "y" not usedunit1.pas(38,3) Note: Local variable "code" not usedunit1.pas(38,8) Note: Local variable "ifreq" not usedunit1.pas(38,14) Note: Local variable "x" not usedunit1.pas(39,3) Note: Local variable "asc" not usedunit1.pas(39,9) Note: Local variable "j" not usedunit1.pas(39,11) Note: Local variable "timsec" not usedunit1.pas(40,3) Note: Local variable "morech" not usedunit1.pas(40,10) Note: Local variable "opened" not used
procedure TForm1.Button2Click(Sender: TObject);var Str: TStringList; Price: string; PriceStr: Packed Array[1..300] of char; cafl: array[0..1000] of Integer; ask,bid,freq,y: Real; code,ifreq,x: Integer; asc,i,j,timsec: LongInt; morech,opened:boolean;begin i:=0;// while i<sizeof(cafl) do while i<1000 do begin cafl[i]:=0; i:=i+1; end; 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.Step:=1; ProgressBar1.StepBy(1); Edit2.text:=inttostr(Str.Count); BidLine.clear; i:=0; while i<Str.Count do begin PriceStr:=Str[i]; morech:=true; Price:=''; j:=1; while morech do begin asc:=ord(PriceStr[j]); if (asc >=$30) and (asc <=$39) or (asc =$2E) then begin Price:=Price+PriceStr[j]; j:=j+1; end else begin if asc =$2C then begin val(Price,freq,code); ifreq:=round(freq); cafl[ifreq]:=cafl[ifreq]+1; Price:=''; j:=j+1; end else morech:=false; end; end; end; ProgressBar1.StepIt; i:=i+1; end; ifreq:=0; while ifreq<sizeof(cafl) do begin x:=ifreq; y:=cafl[ifreq]; BidLine.ADDXY(x,y); ifreq:=ifreq+1; end; Edit2.text:=inttostr(ifreq); end else begin Edit2.text:='File Empty'; end; Str.Free;end;
Str := TStringList.Create;
cafl[ifreq]:=cafl[ifreq]+1;
cafl: array[0..1000] of Integer;