Calling Procedure Set Methods
A Procedure Set method is executed by using a Set statement. The general syntax of the Set statement is:
Set {method-name} [of {object-ID}] {param1 … paramN} To {value1 … valueN}
Where:
- {method-name} is the name of the method that is being executed.
- {object-ID} is a handle to the object whose method is being executed.
- {param1 … paramN} and {value1 … valueN} are all parameters that are passed to the Procedure Set 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, as long as they are of comparable type to the matching parameters in the method declaration.
If you are calling a Procedure Set method of the current object (current instance of the class), 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.
Whether you place your parameters as {param1 … paramN} or {value1 … valueN} is a matter of convention and will differ depending on the specific Procedure Set method you are executing. However, you must pass at least one parameter as value1.
Simple Procedure Set
Procedure Set methods are used primarily to simulate setting a Property. These are called simple Procedure Set methods. The syntax for calling simple Procedure Set methods is:
Set {method-name} [of {object-ID}] To {value}
This is exactly the same as the syntax for setting a property value. Here are some examples of calling a simple Procedure Set method:
// Call some Procedure Set methods of the "current" object
Set Label To "Customer Name:" // set the label of the current object
Set Color To clBtnFace // set the color of the current object
// Call some Procedure Set methods of an "external" object
Set Label of oAddrForm To "Customer Address:"
Set Color of oAddrForm To clGreen
In the above example, oAddrForm is an instance of the Form class. As the above examples show, executing a simple Procedure Set method is indistinguishable from setting a property.
Complex Procedure Set
Some Procedure Set methods are used to set two or more values at once. These are called complex Procedure Set methods. The general syntax for executing a complex Procedure Set is:
Set {method-name} [of {object-ID}] To {value1 … valueN}
Here are some examples of calling complex Procedure Set methods:
Set Location To 10 10 // set location of the current object to 10,10
Set Size To iHeight iWidth
// now execute procedure sets of an "external" object
Set Location of oAddrForm To 10 10
Set Size of oAddrForm To iHeight iWidth
In the above example, oAddrForm is an instance of the Form class.
Notes
Complex Procedure Set methods are being phased out of DataFlex in preference for multiple simple Procedure Set methods or properties.
Procedure Set With Special Parameters
Some Procedure Set methods require special parameters to be passed. The parameters are usually designed to identify which property the method will set from a list or array of similar properties. Common syntax for executing a Procedure Set with parameters is:
Set {method-name} [of {object-ID}] {item-id} To {value}
Where:
- {item-id} denotes the index to an array of properties. {item-id} should be an integer constant, variable, or expression.
The DataDictionary class contains a set of properties that require calling Procedure Set methods with special parameters. The general syntax for calling these Procedure Set methods is:
Set {method-name} [of {object-ID}] Field {file.field-id} To {value}
Set {method-name} [of {object-ID}] File_Field {file.field-id} To {value}
Where:
- {file.field-id} is a data file field identifier (refer to Data File Type for more information). Procedure Set methods that take {file.field-id} parameters exist primarily in the DataFlex DataDictionary class.
Here are some examples of calling Procedure Set methods with special parameters:
For iCount From 0 To 9
Set Array_Value iCount To 0
In this example, the Array_Value method is being called to set the indexed property to 0 for the first 10 items. Some more examples are:
// set some properties of the current object
Set Field_Current_Value Field Customer.Name To "Fred"
Set Field_Mask Field Customer.Phone To "(###)########"
// set some properties of an 'external' data dictionary
Set Field_Default_Value of oOrderDD Field Order.Date To dToday
Set Field_Mask of oOrderDD Field Order.ContactPhone To "(###)########"
Refer to the DataDictionary class in the Class Reference for more information about Field and File_Field properties.
Some Procedure Set methods that require special parameters are also written the following way:
Set {method-name} [of {object-ID}] Item {item-id} To {value}
The Item keyword can be used to designate that the first parameter {item-id} is an item or indexed value. The inclusion or exclusion of the Item keyword has no effect on your program. The use of this keyword is being phased out of DataFlex.