LOTUSSCRIPT LANGUAGE


Property Get/Set statements
Example

Define a property. A property is a named pair of Get and Set procedures that can be used as if they were a single variable.

Syntax

[ Static ] [ Public | Private ] Property { Get | Set } propertyName [ ( [ paramList ] ) ] [ As type ]

[ statements ]

End Property

Elements

Static


Public | Private
Get | Set
propertyName
paramList
type
statements
Usage

The Public keyword cannot be used in a product object script or %Include file in a product object script, except to declare class members. You must put such Public declarations in (Globals).

A property usually consists of two procedures with the same name: a Property Get and a Property Set. However, you are not required to provide both.

A property member of a class cannot be declared Static. That is, a Property Get or Property Set statement within a class definition cannot begin with Static.

Using Property Get

A Property Get procedure is like a function. For example:

' These statements assign the value of saveInt to x
Dim saveInt As Integer
Property Get pInt As Integer
  pInt% = saveInt%
End Property
x = pInt%

Or:

' These statements assign the value of saveInt plus
' increment to x
Dim saveInt As Integer
Property Get pInt (increment As Integer) As Integer
  pInt% = saveInt% + increment%
End Property
x = pInt%(1%)

Using Property Set

A Property Set procedure is the reverse of a Property Get procedure. On entry into a Property Set procedure, an implicitly declared variable whose name and data type are the same as those of the Property Set procedure contains a value to be used inside the Property Set procedure. Inside the Property Set procedure, use the value of the variable instead of assigning a value to it.

Call a Property Set procedure by using its name on the left side of an assignment statement. The value on the right side of the statement is used by the Property Set procedure. For example:

' These statements assign the value of x to SaveInt
Dim SaveInt As Integer
Property Set pInt As Integer
  saveInt% = pInt%
End Property
pInt% = x

Or:

' These statements assign the value of x + increment
' to SaveInt
Dim SaveInt As Integer
Property Set pInt (increment As Integer) As Integer
  saveInt% = pInt% + increment%
End Property
pInt%(1%) = x

Referencing a property that returns an array, list, or collection

If a Get operation returns an array, list, or collection, a reference to the property can contain subscripts according to the following rules:


In a Set operation, the property reference cannot be subscripted. A parenthesized list following the reference must be the argument list. For example, p1(1) is a reference to a property p1 with one parameter; p1(1,2)(3) or p1()(3) is illegal in a Set operation.

Passing a property to a function

A LotusScript property (a property defined by Property Get or Property Set) can be passed to a function by value only, not by reference.

Example
See Also