Sending a Message to Yourself
Often, an object will send a message to itself. This means that the object that is sending the message is also the object receiving the message. When this occurs, the predefined keyword Self can be used to identify the object ID. In the following example, all messages within an object based on this class are sent to itself, so Self is used to identify the object ID of each message.
Class cMyButton is a Button
Procedure Construct_Object
Forward Send Construct_Object
Property Integer piClickCount 0
End_Procedure
Procedure DoAction
Integer iCount
Get piClickCount of Self to iCount
Move (iCount + 1) to iCount
Set piClickCount of Self to iCount
End_Procedure
Procedure OnClick
Send DoAction of Self
End_Procedure
End_Class
Because this type of message sending occurs so often, the {of self} syntax may be omitted. When an object ID is not identified, the current object (self) is assumed. Therefore, the above example could be more easily written as:
Class cMyButton is a Button
Procedure Construct_Object
Forward Send Construct_Object
Property Integer piClickCount 0
End_Procedure
Procedure DoAction
Integer iCount
Get piClickCount to iCount
Move (iCount + 1) to iCount
Set piClickCount to iCount
End_Procedure
Procedure OnClick
Send DoAction
End_Procedure
End_Class