callmethod

edited March 2008 in FastScript
hi, i am a problem with callmethod function.

Example:

SsCRIPT.AddMethod('function Anf_ValorT(Fieldname:string):Variant',CallMethod,EmptyStr,EmptyStr);

and callmethod is:

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



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

if MethodName = 'ANF_VALORT' then
result:=Anf_valorT(Params[0])
end;

Error Delphi: incompatible types: method pointer and regular procedure

Why?

Comments

  • edited 2:10AM
    anmisoft wrote: »
    hi, i am a problem with callmethod function.

    Example:

    SsCRIPT.AddMethod('function Anf_ValorT(Fieldname:string):Variant',CallMethod,EmptyStr,EmptyStr);

    and callmethod is:

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


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

    if MethodName = 'ANF_VALORT' then
    result:=Anf_valorT(Params[0])
    end;

    Error Delphi: incompatible types: method pointer and regular procedure

    Why?


    I think the error is in your function Anf_valorT. The return of that is not equal that you create at
    SsCRIPT.AddMethod('function Anf_ValorT(Fieldname:string):Variant',CallMethod,EmptyStr,EmptyStr);
  • TomBurgenTomBurgen USA, California
    edited 2:10AM
    I agree with desenvsetti. It can be error in function Anf_valorT. Did you check Variant',CallMethod,EmptyStr,EmptyStr?

Leave a Comment