[fpc-pascal]Why TStrings.Add can't work?

mili milimeter at 163.com
Fri Nov 1 11:42:09 CET 2002


Hello, everybody

  I wonder why the following codes will cause a runtime error of "Abstract 
method called"?

>>>>>>

var
  slist:TStrings;
  i:integer;
begin
  slist:=TStrings.Create;
  slist.Add('hello!');
  slist.Free;
end.

<<<<<<

And TStringList is also weird, though run properly, the result is wrong:

>>>>>>

var
  sl:TStringlist;
  i:integer;
  s:String;
begin
  sl:=TStringlist.Create;
  sl.Add('green');
  sl.Add('red');
  sl.Add('blue');
  for i:=0 to sl.Count-1 do begin
    s:=sl.Names[i];
    writeln(s);//Here output a blank line!!!! Why?
  end;
  sl.Free;
end.

<<<<<<



  Thanks,
  mili





More information about the fpc-pascal mailing list