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:

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.

Some examples of calling Function Methods are:

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.