{{fbdoc item="title" value="Operator PROCPTR (Procedure pointer)"}}----
Returns the address of a procedure

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **Procptr** ( [[KeyPgByref|byref]] //identifier// [[KeyPgAs|as]] //proctype// [, //proctype// ] ) [[KeyPgAs|as]] //proctype// [[KeyPgPtr|ptr]]
##
{{fbdoc item="usage"}}##
	//result// = **Procptr** ( //identifier// [, //proctype// ] )
##
{{fbdoc item="param"}}
	##//identifier//##
		A procedure identifier.
	##//proctype//##
		Any type of procedure (sub/function).

{{fbdoc item="ret"}}
	Returns the address of the procedure.

{{fbdoc item="desc"}}
	This operator returns the address of a ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## procedure.
	
	When using the two arguments ##PROCPTR( //identifier//, //type// )## syntax, this allows of getting procedure pointer for based on sub/function type.
	This makes it possible to explicitly specify the 'type' of the sub/function, to resolve procedure overloads or make a check for compatible sub/function on non-overloaded procedures.
	
	##[[KeyPgOpAt|Operator @ (Address of)]]##, when used with procedures, behaves the same as ##**Procptr**## without its optional argument (the second).

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/operator/procptr.bas"}}%%(freebasic)
' This example uses ProcPtr to demonstrate function pointers
Declare Function Subtract( x as Integer, y as Integer) as Integer
Declare Function Add( x as Integer, y as Integer) as Integer
Dim myFunction as Function( x as Integer, y as Integer) as Integer

' myFunction will now be assigned to Add
myFunction = Procptr( Add )
print myFunction(2, 3)

' myFunction will now be assigned to Subtract.  Notice the different output.
myFunction = Procptr( Subtract )
print myFunction(2, 3)

Function Add( x as Integer, y as Integer) as Integer
	return x + y
end function

Function Subtract( x as Integer, y as Integer) as Integer
	return x - y
end function
%%
	{{fbdoc item="filename" value="examples/manual/operator/procptr2.bas"}}%%(freebasic)
Sub s Overload()
End Sub

Sub s( ByVal i As Integer )
End Sub

'----- since fbc 1.09.0, ProcPtr supports a second parameter (optional):
Var s1 = ProcPtr( s, Sub() )
Var s2 = ProcPtr( s, Sub( ByVal i As Integer ) )

'----- before fbc 1.09.0, it was only possible with:
'Dim s1 As Sub()
's1 = ProcPtr( s )
'Dim s2 As Sub( Byval i As Integer)
's2 = ProcPtr( s )
%%
{{fbdoc item="ver"}}
	- Before fbc 1.09.0, the second argument (the optional) was not supported.

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Procptr""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgSub|Sub]]##
	- ##[[KeyPgOpVarptr|Varptr]]##
	- ##[[KeyPgOpStrptr|Strptr]]##
	- [[ProPgPointers|Pointers]]

{{fbdoc item="back" value="CatPgOpPoint|Pointer Operators"}}{{fbdoc item="back" value="CatPgOperators|Operators"}}