Link to home
Start Free TrialLog in
Avatar of user_
user_

asked on

Tstrings , Abstract Error ?

the following code raise the runtime error (abstract error )
 whats the problem ?

var Txt:Tstrings;
begin
Txt:=Tstrings.create;
Txt.add('some text'); // Error raised here
Txt.free
end;
ASKER CERTIFIED SOLUTION
Avatar of knightmad
knightmad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of knightmad
knightmad

I have to add the technical explanation for the 'abstract error' raised.

in unit classes.pas you can see the TString's source code.

function TStrings.Add(const S: string): Integer;
begin
  Result := GetCount;
  Insert(Result, S);
end;

but TString's Insert method is abstract, and this raise the runtime error. As I said before, use TStringList or derive TStrings yourself : )

Regards,

Fernando - Brasil
Avatar of user_

ASKER

i used TStringList  before but i want to know what cause the error

thankx  Fernando