Still I Have Problem With Adding Custom Functions.

Hi All,
After reading the Manual Help Of FastReport and COPY & PASTE the example of
it ( Manual Help) in my project same as the example source code ,still i have problem and "CallMethod" function doesn't executed,So My Custom Function Doesn't run Too.!!!.
( I Found That with putting one Break-Point in first line of "CallMethod" function. )
I mixed Up.Also I recieve the following error when i press the "Preview" Button in IDE:
Invalid Variant Type Conversion.

I use the following source code as follows:


//
start

unit myfunctions;
interface
implementation
uses SysUtils, Classes, fs_iinterpreter;
type
TFunctions = class (TObject)
private

function CallMethod(Instance: TObject; ClassType: TClass; const
MethodName: String ; var Params: Variant): Variant;
public

constructor Create;
destructor Destroy; override ;
end;
var
Functions: TFunctions;
function MyFunc(s: String ; i: Integer): String;
begin
RESULT :='Test Functions';
end;

{ TFunctions }
constructor TFunctions.Create;
begin
with fsGlobalUnit do
begin

AddedBy := Self;
AddMethod('function MyFunc(s: String; i: Integer): String',
CallMethod, 'My functions', 'The MyFunc function always returns True');
AddedBy := nil ;
end;
end;
destructor TFunctions.Destroy;
begin
if fsGlobalUnit <> nil then

fsGlobalUnit.RemoveItems(Self);
inherited;
end;
function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String ; var Params: Variant): Variant;
begin
if MethodName = 'MYFUNC' then

Result := MyFunc(Params[0], Params[1])
else if MethodName = 'MYPROC' then

MyProc(Params[0]);
end;
initialization
Functions := TFunctions.Create;
finalization
Functions.Free;
end.
//
end


Please Help me
Thanks in Advance.
Regards.

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.