Skip to main content

Assigning Default Values

The next property, TicketsSold, illustrates the use of another data type,%IntegerOpens in a new tab, to store numeric values:

Property TicketsSold As %Integer [ InitialExpression = 0 ];

Use the New Property Wizard to add TicketsSold. While defining the property add an index like we did for Title.

Index TicketsSoldIndex On TicketsSold;

Because our property name consists of two words, you might be tempted to put a space or a hyphen between “Tickets” and “Sold” but you cannot. Caché does not accept punctuation characters within names. In general this doesn't matter, because users of an application never see property names. They're only of interest to application developers.

We have also specified an initial value, 0, that will automatically be assigned to TicketsSold whenever a new Film object is created. Note that the specification we enter here is an expression. It could be a literal value, such as 0, or a calculation that computes an initial value based on other variables or functions.

We can set the initial value for the property by either adding “[ InitialExpression = 0 ]” to the Property statement in the Class Editor window or by using the Studio Class Inspector Window....

FeedbackOpens in a new tab