|
Properties is a special kind of local functions. Is a syntactical convenience and can be described quite accurate as "programmatic variables". A property has parameters as a local function does and returns a value but also and more important we can use the assignment operator to "write" something to a property. Every property has three code sections.
Special keywords are used to separate the various sections:
The above property prp reads and writes a value in the even positions of the array a. As we can see there are two keywords, GETVALUE and SETVALUE which separate the three property sections. These keywords can be put in the above order only and are both mandatory. The code above GETVALUE is the common section. It is executed every time the property is used in the code, either to get a value or to assign a value. The section under SETVALUE is executed only when a value is assigned to the property. The code under GETVALUE is executed only when we read property's value.
The first line of the above code reads the value of the element 20 of the array a. The second line writes the value of 1000 at element 40 of the array a. Every piece o CalcIt code can declare properties. Properties have important use in Class definitions. See Local functions. |