Userfunction Exception Incompatible types
Hello,
I have defined a Userfunction, using the descrped way 2.
1. I Called xxxReport.AddFunction with the corresonding Params
2. I implemented the "OnUserFunction" Event
3. I checked function name in uppercases
The Function is listed in the report designer and I call it within "OnStartReport"
If I run the report from within the designer or from delphi code, I get an Error Message from the parser:
Script error at 10:33: Incompatible types: 'Class String', 'String'
What is wrong?
I'm actually working with a trial version of Fastreport 3.19
Working with Delphi 2005 on XP Prof. SP1
Regards, Ren?©
I have defined a Userfunction, using the descrped way 2.
1. I Called xxxReport.AddFunction with the corresonding Params
2. I implemented the "OnUserFunction" Event
3. I checked function name in uppercases
The Function is listed in the report designer and I call it within "OnStartReport"
If I run the report from within the designer or from delphi code, I get an Error Message from the parser:
Script error at 10:33: Incompatible types: 'Class String', 'String'
What is wrong?
I'm actually working with a trial version of Fastreport 3.19
Working with Delphi 2005 on XP Prof. SP1
Regards, Ren?©
Comments
Try with other parameter.
I've allready tried it with Integers instead. Same problem;
Incompatible types: 'Class Integer', 'Integer'
Any other idea?
In Delphi: In Script: You do in the same way?
To be sure, I included your Code snippets.
But..... It's the same result. So it might be a problem with the trial version ?
Thanks for your reply
Thanks in advance !
For info, I use it this way :
In delphi :
In FR :
Maybe I shouldn't use angle brackets anymore but [] instead ?
has worked fine for me in all versions
delphi function declared at start of implementation section of form
function DaysBetween(Date1, Date2: TDateTime): Longint;
begin
Result := Trunc(Date2) - Trunc(Date1);
if Result < 0 then Result := 0;
end;
declare in on show or oncreate of form not when loading report, passes out 2
dates and return integer difference
frxReport2.AddFunction('function DateDif2(olddate, newdate: TDateTime): Integer','Userfunctions','returns integer value of newdate - olddate');
function TForm1.frxReport2UserFunction(const MethodName: String;
var Params: Variant): Variant;
begin
if AnsiCompareText(MethodName, 'Datedif2') = 0 then
Result := daysbetween(Params[0], Params[1]);
end;
make sure method name matches declaration case sensitive
you should not need []
since you are working with strings you may need to add extra '''' when passing result back in.
I was using 3.19.2
I just installed 3.19.13 and things work correctly now.
Sorry for bothering and thanks again for your help.
(and sometimes Incompatible types: 'Class String', 'string')
with a IBObjects related report with a few script lines and a simple
alternating memo field color change on alternate lines. The memofields
are straight forward map to a dataset and fieldname.
if ((<LINE#> mod 2) = 0) then
memName1.Color := clSilver
else
memName1.Color := clNone;
FastReport Pro 3.24, Delphi 7 pro
Steve Fields