Revision [22340]

This is an old revision of KeyPgFunctionPtr made by JeffMarshall on 2018-06-28 10:46:19.



Data type that stores a pointer to a FUNCTION procedure returning a value

dim variable as Function [CDecl|Pascal|StdCall] [( [parameter_list] )] [ ByRef ] [As return_type] [= initializer]

parameter_list: parameter[, parameter[, ...]]
parameter: [ByRef|ByVal] identifier [As type] [= default_value]
identifier: the name of the variable referenced in the subroutine
type: the type of variable
default_value: the value of the argument if none is specified in the call
return_value: the value returned from the function
intializer: address of a subroutine to set as the intial value

A Function pointer is a procedure pointer that stores the memory location of compiled code that returns a value. If no intializer is given the default initial value is zero (0).

The memory address for the Function procedure can be assigned to the variable by taking the address of a subroutine with ProcPtr or Operator @ (Address of).

The procedure must match the same Function declaration as the declared Function pointer.

To call the subroutine assigned, use the variable name as if it were a normal declared Function.

Function ConcatSelf( x As String ) As String
    Return x & x
End Function

Dim x As Function( x As String ) As String = ProcPtr( ConcatSelf )

Print x( "Hello" )

Differences from QB:
See also:
Back to Standard Data Types
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode