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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.