Skip to main content

Calculated (Property Keyword)

Specifies that this property has no in-memory storage allocated for it when the object containing it is instantiated.

Usage

To specify that the property has no in-memory storage allocated for it, use the following syntax:

Property name As classname [ Calculated ];

Otherwise, omit this keyword or place the word Not immediately before the keyword.

Details

This keyword specifies that the property has no in-memory storage allocated for it when the object containing it is instantiated.

Use this keyword when you are defining a property that does not need any in-memory storage. There are two ways to specify a value for this property:

  • Define a Get (and possibly a Set) method for the property. For example, for an Age property, you could provide an AgeGet method that determines a person’s current age based on the current time and the value of their DateOfBirth property. See Using and Overriding Property Methods.

  • Define this property as a computed property; this uses the SqlComputed keyword and related keywords. See Defining a Computed Property.

Subclasses inherit the Calculated keyword and cannot override it.

To include a property with the Calculated keyword in an index for a SQL table, you must also specify the SqlComputed and SqlComputeCode keywords as well. If you try to compile the class with an index on a Calculated property, without also specifying the SqlComputed and SqlComputeCode keywords on the property, the system returns the following error message:

ERROR #5414: Invalid index attribute: <classname>::<indexname>::<propertyname>
ERROR #5030: An error occurred while compiling class <classname>

Default

The default value for the Calculated keyword is false.

Example

Property Age as %Integer [ Calculated ];

See Also

FeedbackOpens in a new tab