Show: Object Pascal C++
Display Preferences

E2148 Dynamic method or message handler not allowed here (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

Dynamic and message methods cannot be used as accessor functions for properties.


program Produce;

  type
    Base = class
      v : Integer;
      procedure SetV(x : Integer); dynamic;
      function GetV : Integer; message;
      property Velocity : Integer read GetV write v;
      property Value : Integer read v write SetV;
    end;

  procedure Base.SetV(x : Integer);
  begin v := x;
  end;

  function Base.GetV : Integer;
  begin GetV := v;
  end;

begin
end.

Both 'Velocity' and 'Value' above are in error since they both have illegal accessor functions assigned to them.


program Solve;

  type
    Base = class
      v : Integer;
      procedure SetV(x : Integer);
      function GetV : Integer;
      property Velocity : Integer read GetV write v;
      property Value : Integer read v write SetV;
    end;

  procedure Base.SetV(x : Integer);
  begin v := x;
  end;

  function Base.GetV : Integer;
  begin GetV := v;
  end;

begin
end.

The solution taken in this is example was to remove the offending compiler directives from the procedure declarations; this may not be the right solution for you. You may have to closely examine the logic of your program to determine how best to provide accessor functions for your properties.

Personal tools
In other languages