Reading Property Values
Object properties are read by executing a Get statement. The syntax of the Get statement is:
Get {property-name} [of {object-ID}] To {variable-id}
Where:
- {property-name} is the name of the property that is being read.
- {object-ID} is a handle to the object whose property is being read.
- {variable-id} is the name of a variable that will receive the property's value. The receiving variable can be any variable that is of a compatible type to the property.
If you are reading a property of the current object (the current instance of the class), you can use the Self keyword as the object-ID. Refer to the section on The Self Keyword for more details. Alternatively, you can omit the object-ID clause completely, and DataFlex will automatically reference the current object.
An example of a class declaration that reads properties of the current object is:
Class cCount_Button is a Button
// Constructor:
Procedure Construct_Object
Forward Send Construct_Object // very important!
Property Integer piClickCount 0
End_Procedure
Procedure OnClick
Integer iCount
Get piClickCount To iCount
Move (iCount + 1) To iCount
Set piClickCount To iCount
Set Label To iCount
End_Procedure
End_Class
The above example declares a class based on the Button class, with a new property, piClickCount. The button class is designed to execute a method called OnClick each time the button is clicked by the mouse (this is called an event method). The OnClick method has been defined to read the piClickCount property into a variable, increment it, set the property back to its incremented value, and also display the value in the button's label (by setting the label property).
If you are reading a property of some other object, you need to provide a handle to that object in the {object-ID} part of the Get statement. The DataFlex Handle type can be used to create variables or properties for storing object handles. Examples of Get statements that read properties of some external objects are:
Get Checked_State of oMarried_Checkbox To bChecked
Get Minimum_Position of oSpinForm To iMax
Get Maximum_Position of oSpinForm To iMin
In the above examples, oMarried_Checkbox is an instance of the Checkbox class, and oSpinForm is an instance of the SpinForm class. Both of these classes are built into the DataFlex class library.