I am trying to import some text on multiple lines into my app and then process in a function (ProcessSearch2), But I get any error as soon as I start the import which reads
'list index out of bounds (63) problem'
Where am I going wrong in the following?
'list index out of bounds (63) problem'
Where am I going wrong in the following?
Code:
procedure TMainForm.CdrButtonOKClick(Sender: TObject);
var
i: integer;
k : integer;
sl : TStringList;
begin
CdrButtonOK.Enabled := False;
CdrImportEdit.Enabled := False;
LB_query.Lines.Clear;
Label4.Visible := False;
sl := TStringList.Create;
try
sl.LoadFromFile(CdrImportEdit.Text);
Progressbar1.Position := 1;
k := 0;
ProgressBar1.Max := sl.Count;
ProgressBar1.Visible := True;
//loop though each line of text
for i := 0 to sl.count - 1 do
begin
if copy(sl[i],1,6) = '------'
then begin
if copy(sl[i],34,4) = 'LINE' then begin
StrArg := Copy(sl[i],12,19)+' '+Copy(sl[i],41,4)+' '+Copy(sl[i],53,4);
StrArg1 := StrArg1+StrArg;
end
else
StrArg := Copy(sl[i],12,19)+' '+Copy(sl[i],52,4)+' '+Copy(sl[i],40,4);
StrArg1 := StrArg1+StrArg;
end
end;
if copy(sl[i],12,6) = 'INCOMI'
then begin
StrArg := ' In '+Copy(sl[i],47,4)+' ';
StrArg1 := StrArg1+StrArg;
end;
if copy(sl[i],12,6) = 'OUTGOI'
then begin
StrArg := ' Out 0.00';
StrArg1 := StrArg1+StrArg;
end;
if copy(sl[i],12,6) = 'DIGITS'
then begin
StrArg := ' '+Copy(sl[i],29,20);
StrArg1 := StrArg1+StrArg;
end;
if copy(sl[i],12,6) = 'CALL R'
then begin
StrArg := ' '+Copy(sl[i],1,8);
StrArg1 := StrArg1+StrArg;
Index := 1;
end;
if Index>0 then begin
ProcessSearch2(StrArg1);
Index:=0;
StrArg1 :='';
end;
k := k+1;
Progressbar1.Position := k;
finally
CdrButtonOK.Enabled := True;
CdrImportEdit.Enabled := True;
ProgressBar1.Visible := False;
Label4.Visible := True;
Label4.Caption := 'Import Complete';
sl.free;
end;
end;