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 6:47AM
    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 6:47AM
    I agree with desenvsetti. It can be error in function Anf_valorT. Did you check Variant',CallMethod,EmptyStr,EmptyStr?

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.