Property Statement
Language Items List
Definition:
Used to define a new procedural property. A "procedural" property is similar
to a regular property in that it associates a name with access to a piece of
data of a certain type. The method for setting and retrieving this data, however,
is unique.
Syntax:
Property<PropertyName>Get<GetFunctionName>[Set<SetSubName>]As<type>
Syntax Description
PropertyName The name of a procedural property.
GetFunctionName The name of the function to run to retrieve the current value
SetSubName The name of the Sub to run to set the current value.
type The type of the property, such as Integer or Object. Any type that it is valid
to specify for a Function is valid here.
The syntax for GetFunctionName is as follows:
Function GetFunctionName() As type
GetFunctionName = <current value>
End Function
Sub SetSubName(newValue as type)
<current value> = newValue
End Sub
The function must take no arguments and must be defined to return the same
type declared with the procedural property. The sub must take a single argument of
the same type as the procedural property.
Details:
Procedural properties are useful when:
the data requires special validation rules.
the representation of the data is externally held. (e.g. Visibility of Window).
the setting of the data requires side affects.
Using Procedural properties can reduce the housekeeping overhead that is
usually associated with trying to maintain two versions of the same thing. Like
trying to keep track of whether a window is visible or not. This is error-prone if
done with anything except a procedural property that is really a transparent
mechanism for getting and setting the "real" state of the data.
To set the value of the property the "SetSubName" Sub is called. To retrieve
the current value of the property the "GetFunctionName" is called. Hence the
name "procedural." Procedures are run to access the data. This allows for a great
degree of flexibility in how the data is represented.
Note: Since the Set syntax is optional, it is possible to make a property that can
have its value queried, but not set. This corresponds to a ReadOnly property.
When calling SetSubName, it is not required to accept the given value. Just
like any fundamental data type, value validation can be performed and certain
sets can be ignored. If they are ignored, they can be ignored silently, or they
can throw an interpretive exception, as shown in the following:
Sub SetSubName(newValue as Integer)
If (newValue <= 0) Then Throw IllegalSetValue(newValue)
...
End Sub
This type of validation could correspond to a procedural property that is
defined to take only positive non-zero values.