[fpc-pascal]TStringList index

Vincent Snijders vslist at zonnet.nl
Sun Mar 14 20:24:50 CET 2004


On Sun, 14 Mar 2004 11:04:34 -0800
Taj Morton <taj at wildgardenseed.com> wrote:

> Hi all,
> This code has been driving me nuts for the past week.
You have to add them to the list, before you can access them. 
>    IDs:=TStringList.Create;
Creates a list without elements
>       for i:=0 to Datab.List_Field.Count-1 do
>       begin
> 	 Tmp:=TStringList(Datab.List_Field.items[i]);

> 	 IDs.Strings[i]:=Tmp.Strings[0];
Instead do:
	 IDs.Add(Tmp.Strings[0]);
> 	 Tmp.Free;
>       end;
> 
> It crashes with 
> An unhandled exception occurred at 0x08062FE5 :
> ESTRINGLISTERROR : List index exceeds bounds (0)
>   0x08062FE5
> 
> Datab.List_Field.Count-1=18. It appears that IDs is not letting me write to 
> item i. Any ideas?
> Thanks, Taj

Vincent.





More information about the fpc-pascal mailing list