Calling Function Methods
Calling a Function method is complementary to calling a Procedure Set method (i.e., if a Procedure Set method is used to set a property, then there is usually a Function method that is used to read it). A Function method is executed by using a Get statement. The general syntax of the Get statement is:
Get {method-name} [of {object-ID}] {param1 … paramN} To {receiving-variable}
where:
- {method-name}: The name of the Function method that is being executed.
- {object-ID}: A handle to the object whose method is being executed.
- {param1 … paramN}: All parameters that are passed to the Function method.
- {receiving-variable}: The variable that is assigned the value returned by the Function 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 Function 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.
Function methods are often used, in conjunction with Procedure Set methods, to simulate a Property. If the Function method does not contain any parameters, then the syntax for calling the method is identical to reading a property.
Examples of Calling Function Methods
Here are some examples of calling Function methods:
Get Can_Delete To bCanDelete
For iCount From 0 To 9
Get String_Value of oAnArray iCount To sValue
Showln sValue
Loop
// Call some function methods of the current object
Get Field_Current_Value Field Customer.Name To sName
Get Field_Mask Field Customer.Phone To sPhoneMask
// Call some function methods of an 'external' data dictionary
Get Field_Default_Value of oOrderDD Field Order.Date To dOrderDate
Get Field_Mask of oOrderDD Field Order.ContactPhone To sMask
Refer to the DataDictionary class in the Class Reference for more information about Field and File_Field properties.