on user function variant error

ibrahim bulutibrahim bulut turkey
edited 7:01PM in FastReport 4.0
i have declared my function and passed it to fastreport
if i don't use an expression in function parameter is work good,
if i use an expression with function parameter i get variant error
"colud not convert variant of type (array variant) into string"

code is that
Function Func1(S1,S2 : string) : string;
begin
// func code is here
end;

frxReport1.AddFunction('Function Func1(S1,S2:String): String');

if i use
[Func1(<frxDBDataset1."STRINGFIELD1">,<frxDBDataset1."STRINGFIELD2">)]
function work perfect

if i use
[Func1(<frxDBDataset1."STRINGFIELD1">,[<frxDBDataset1."STRINGFIELD1">+<frxDBDataset1."STRINGFIELD2">])]

i get convert error exception

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:01PM
    Hi Ibrahim
    drop the inner set of [] braces.
    ;)
  • ibrahim bulutibrahim bulut turkey
    edited 7:01PM
    thanks gord,
    i have solved it another way

    function TForm1.frxReport1UserFunction(const MethodName: string;
    var Params: Variant): Variant;
    Var
    I : Integer;
    VValue : Variant;
    VDizi : Array of Variant;
    begin
    if MethodName = 'FUNC1' Then
    Begin
    try
    VDizi:=Params[1];
    for I:=VarArrayLowBound(VDizi,VarArrayDimCount(VDizi)) to
    VarArrayHighBound(VDizi,VarArrayDimCount(VDizi)) do VValue:=VDizi;
    except
    VValue:=Params[1];
    end;

    Result:=Func1(Params[0],VValue);
    End;
    end;


    if the parameter is an array of variant, no problem

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.