CalcIt Commands

PROPERTY PropName(...);

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.

  1. Common. The code in common section is executed either for read or write operations.
  2. For Read operations. The code in Read section is executed when we read its value.
  3. For Write operations. The code in write section is called when we assign a value to the property using the assignment operator. The value assigned to a property is passed through the RESULT command.

Special keywords are used to separate the various sections:

set a(100);

property prp(i);

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.

x:=prp(10);    //read operation
//write operation

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.

Go Back