How to pass a method into a function

BlitzMax Forums/BlitzMax Programming/How to pass a method into a function

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You could implement a SendMessage() method that all types have anyway and have the function call it.

Its not the same thing but can be used similiar:
Strict
Type Ta
	Method SendMessage:Object( message:Object,sender:Object )
		If String(message)="b"
			Print "the message is b"
			
		ElseIf String(message)="c"
			Print "the message is c"
		Else
			Print "unknown message"
		EndIf
	EndMethod
End Type

Local a:Ta = New Ta

test(a,"b")
test(a,"c")
test(a,"x")

Function test(z:Object,s:String)
	z.SendMessage(s,Null)
	Print "something"
End Function