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?©

Comments

  • edited 8:30AM
    You will send but parameter type String?
    Try with other parameter.
  • edited 8:30AM
    Thanks for the reply.

    I've allready tried it with Integers instead. Same problem;
    Incompatible types: 'Class Integer', 'Integer'

    Any other idea?
  • edited 8:30AM
    I working in Delphi 7 and shall create the function so:

    In Delphi:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    frxReport1.AddFunction('function MyFun(x:String):String','User Function','');
    frxReport1.DesignReport;
    
    end;
    
    function TForm1.frxReport1UserFunction(const MethodName: String;
      var Params: Variant): Variant;
    begin
    Result:=0;
    if MethodName ='MYFUN' then
    Result:=UPPERCASE(Params[0]);
    end;
    
    In Script:
    begin
    Memo2.text:=MyFun(Memo1.text);
    end.
    
    You do in the same way?
  • edited 8:30AM
    Hello Den,

    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
  • edited 8:30AM
    Maybe it is problem in Delphi 2005.
  • edited November 2005
    I have the same problem in D7 with 3.19 standard. It worked in 3.17. Haven't checked for 3.18. This is urgent since my apps don't work anymore.

    Thanks in advance !

    For info, I use it this way :

    In delphi :
    repx.AddFunction('Function GETAD(cocv:String):String');
    

    In FR :
    CurAD:=GetAD(<frxkbm."cocv">);
    

    Maybe I shouldn't use angle brackets anymore but [] instead ?
  • gordkgordk St.Catherines On. Canada.
    edited 8:30AM
    here is a sample using dates and integer return.
    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.
    ;)
  • edited November 2005
    Hello gordk.

    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.
  • fields24fields24 Tennessee
    edited 8:30AM
    I am getting this error, Incompatible types: 'Class Integer', 'Integer'
    (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
  • gordkgordk St.Catherines On. Canada.
    edited 8:30AM
    where are you writing the code, in the obp event of the memo or the data band containing the memo?
    >

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.