Clarification on passing class-type parameters into functions and procedures

edited August 2023 in FastReport VCL 5

I am trying to use in a beforePrint on the fastCode side a custom function registered on the code side.

The special feature of this function is that one parameter is a var class that should be returned to the pascalCode. When i call function the program gives invalid Typecast error.

After reading the documentation of fastReport i found this:

https://www.fast-report.com/public_download/docs/FRVCL/online/en/DeveloperManual/en-US/Custom_Functions_Connection_to_Report.html 

I would like to understand if in fact it is not possible to pass complex objects to procedures and functions even while registering the relevant class or if there is a way for do it.

My code:

Delphi code:

function GetTypeCliFor(var ATypeClientSupplier: TTypeCliFor): Boolean;
 
with Script.AddClass(TTipoCliFor, 'TComponent') do
begin
  AddProperty('FlEstero', 'Integer', GetProp1);
  AddConstructor('constructor Create', CallMethod);
  AddMethod('procedure Free', CallMethod);
  AddMethod('function ClassName: String', CallMethod);
end;

PascalScript:

procedure ValorizzaQuantita;
var
 LTipoCli: TTipoCliFor;
begin 
  GetTipoCliFor(LTipoCli);
end;

Thank you, any opinions and suggestions are welcome.

Leave a Comment