Calling Procedure Methods
A procedure method is executed by calling the method. This is sometimes referred to as sending a message. The syntax for calling a procedure method is:
Send {method-name} [of {object-ID}] {param1 … paramN}
Where:
- {method-name} is the name of the procedure method being executed.
- {object-ID} is a handle to the object that will receive the instruction to execute the method.
- {param1..paramN} are the parameters that you are passing to the called method.
The order of the parameters must match the list of parameters in the method's declaration. The parameters you pass can be either constants, variables, or expressions, so long as they are of comparable type to the matching parameters in the method declaration.
If you are calling a method of the current object (current instance of the class), then you can use the self keyword as the object-ID. Refer to the Self Keyword section for more details. Alternatively, you can omit the object-ID clause completely, and DataFlex will automatically reference the current object.
Examples of Calling Procedure Methods
Examples of calling procedure methods follow:
Class cMyEdit is a Edit
Procedure DoAddName
String sName
Get psName To sName
Send Append_Text sName
// same as writing Send Append_Text of Self sName
End_Procedure
Procedure Construct_Object
Forward Send Construct_Object
Property String psName Public "John"
On_Key Key_Alt+Key_D Send DoAddName
End_Procedure
End_Class
The above example declares a class cMyEdit based on the Edit class. The Construct_Object procedure defines an accelerator key (Alt+D) that will call the DoAddName method. The DoAddName method will read a string property and append it to the end of the text by calling the inherited Append_Text method.
If you are calling a method of some other object, then you need to provide a handle to that object in the {object-ID} part of the Send statement. The DataFlex handle type can be used to create variables or properties for storing object handles. Examples of Send statements that call methods of some external object are:
Send Beginning_of_line of oEdit
Send Goto_Line of oEdit iLineNumber
Send Move_Absolute of oEdit 20 5
In the above example, oEdit is an instance of the Edit class.