^FUNCPTR

Assign a routine to a delegate

 

 

 

NSupported in Synergy .NET
^FUNCPTR(routine)

Arguments

routine

A subroutine, function, or method path that you want a delegate to call. (a)

Discussion

The ^FUNCPTR data reference operation enables you to assign a subroutine, function, or method to a delegate so you can then call that routine from the delegate.

If routine is not a subroutine, function, or method path, the compiler will report a NOTALLOWED error (“Non-routine path not allowed in ^funcptr”). When trying to match a subroutine, function, or method with parameters to a delegate, make sure the parameter passing convention also matches; otherwise, you'll get a TYPMISMCH error.

See also

DELEGATE-ENDDELEGATE

Examples

subroutine sub1
proc
    Console.WriteLine("sub1");
    xreturn
end

function func1, int
    byval parm1, string
proc
    Console.WriteLine("func1");
    freturn 0
end

main
proc
    data delegate1, @Action
    delegate1 = ^funcptr(sub1)
    delegate1()

    data delegate2, @Func<string, int>
    delegate2 = ^funcptr(func1)
    delegate2("hey")
end