on user function variant error
ibrahim bulut
turkey
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
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
drop the inner set of [] braces.
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