Sendmessage

BlitzMax Forums/BlitzMax Beginners Area/Sendmessage

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.

SuperStrict

' Generic class for all messages, individual instances are the actual messages. It would
' be more convenient to use integer constants but SendMessage requires two
' objects so it's a bit easier to just create "dummy" objects to serve as the messages.
' Note that you only need to create each instance ONCE, or this system doesn't work -
' the only reason a message means "STOP" is because it is stored in the MSG_STOP
' variable.
Type TMsg
EndType

' Create a new instance for the hello message
Global MSG_HELLO:Object = New TMsg


Type TFoo
	
	Method SendMessage:Object(Message:Object, Param:Object = Null)
		' See which message was sent
		Select Message
			Case MSG_HELLO
				Print "Hello object."
		EndSelect
	End Method
	
End Type

'begin
Local foo:TFoo = New TFoo

foo.sendMessage(MSG_HELLO) 

End


(Blueapples helped me with this one before)