fb:porticula NoPaste
FuncSubPointer Vergleich
Uploader: | MOD |
Datum/Zeit: | 11.06.2011 19:40:30 |
'Beispiel für Function- und Subpointer im Zusammenhang mit UDTs
'Auskommentieren oder verändern um Functionvariante zu testen, sonst Subvariante
#Define subVariante
#Ifdef subVariante
Type foo
dummy As Integer = 5
Declare Sub bar ()
Declare Static Sub bar (baz As foo)
tFunc As Sub ()
End Type
Sub foo.bar ()
Print this.dummy
End Sub
Sub foo.bar (baz As foo)
baz.bar()
End Sub
Sub sonstiges ()
Print 7
End Sub
Dim As foo tester
tester.tFunc = @sonstiges
Dim As Sub (baz As foo) testFunc1 = @foo.bar
Dim As Sub () testFunc2 = @sonstiges
testFunc1(tester)
testFunc2()
tester.tFunc()
Sleep
#Else
Type foo
dummy As Integer = 5
Declare Function bar () As Integer
Declare Static Function bar (baz As foo) As Integer
tFunc As Function () As Integer
End Type
Function foo.bar () As Integer
Return this.dummy
End Function
Function foo.bar (baz As foo) As Integer
Return baz.bar()
End Function
Function sonstiges () As Integer
Return 7
End Function
Dim As foo tester
tester.tFunc = @sonstiges
Dim As Function (baz As foo) As Integer testFunc1 = @foo.bar
Dim As Function () As Integer testFunc2 = @sonstiges
Print testFunc1(tester)
Print testFunc2()
Print tester.tFunc()
Sleep
#EndIf