Caché Class Definition Reference
InitialExpression
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Specifies an initial value for this property.
Usage
To specify an initial value for this property, use the following syntax:
Property name As classname [ InitialExpression = initialexpression ];
Where initialexpression is a constant or a Caché ObjectScript expression enclosed in curly braces.
Details
This keyword specifies an initial value for the property. This value is assigned by the %New() method of the class when a new instance is created. (If a property is transient, then its initial value is determined either by code invoked by %New() when the instance is created or by code invoked by %OpenId() when the instance is loaded from disk into memory.)
The value of the initial expression must be suitable for the given property type.
The expression can be arbitrarily complex, with the following limitations:
Subclasses inherit the value of the InitialExpression keyword and can override it.
Default
The default value for the InitialExpression keyword is null.
Examples
The following shows several examples that use Caché ObjectScript expressions:
Property DateTime As %Date [ InitialExpression = {$zdateh("1966-10-28",3)} ];

Property MyString As %String [ InitialExpression = {$char(0)} ];

/// this one is initialized with the value of a parameter
Property MyProp As %String [ InitialExpression = {..#MYPARM} ];

/// this one is initialized by a class method
Property MyProp2 As %Numeric [ InitialExpression = {..Initialize()} ];
See Also