I wrote a scriptlanguage for my applications and my goal is to make it possible to publish any type from delphi in the script. I use rtti to automatize this task. For any instance type like classes I use the following code to find and call a method from script.
var Info : TRttiType;
Meth : TRttiMethod;
Param : TArray<TValue>;
Result : TValue;
AnyClass : TClass;
begin
...
Info := RttiContext.GetType(AnyClass);
Meth := Info.GetMethod('AMethod');
Setlength(Param, 1);
Param[0] := TValue.From<Integer>(11);
Result := Meth.Invoke(ClassInstance, Param);
...
end;
But with a record this code doesn't work, because the TRttiMethod type doesn't offer an Invoke() method for record types. I can access the method infos by Info.GetMethod('AMethod') from the record type.
For example i have a record like this:
TRecordType = record
Field1, Field2 : single;
procedure Calc(Value : integer);
end;
So does anyone know a way to invoke a method from a record if i have methodname or methodaddress?