[fpc-pascal]How to obtain runtime type of class object in debugger ?

Anton Tichawa anton.tichawa at chello.at
Tue Feb 25 13:54:35 CET 2003


Hello, Olle!

One possibility is:

type
  TClassA = class(TObject);

Your classes then inherit all methods of TObject, including TObject.ClassType 
and TObject.InheritsFrom. So it's possible to write things like:

procedure P(x: TClassA);
begin
  if x.ClassType = TClassA then begin
    bla bla
  end else if x.ClassType = TClassB then begin
    bla bla
  end;
  if x.InheritsFrom(TClassC) then begin
    // true for TClassC and descendants
    bla bla
  end;
end;

hth,

Anton.

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte 
Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
mobil: +43 664 52 07 907
email: anton.tichawa at chello.at

----------



More information about the fpc-pascal mailing list