Set statement (LotusScript® Language)

Assigns an object reference to a variable, or associates an object with a variable.

Use one of the following three syntaxes:

Syntax 1: Create an object and assign a reference

Set var = New class [ ( [ argList ] ) ]

Elements

var

A Variant variable, an object of the class class, an object of a class derived from class, or any variable element that accepts an object reference, such as an element of an array, list, or user-defined data type.

class

The name of the user-defined or product class of the object to be created.

argList

For user-defined classes, argList is the comma-separated list of arguments required by the class constructor sub New, defined in the class named by type. For product classes, consult the product documentation.

Syntax 2: Copy an existing object reference to another variable

Set var1 = var2

Elements

var1

A Variant variable, an object of the same class as var2, an object of a class derived from var2's class, or any variable element that accepts an object reference, such as an element of an array, list, or user-defined data type.

var2

An expression whose value is NOTHING, an object reference of the same class as var1, an object reference of a class derived from var1's class, or an object reference of a class from which var1 is derived. In the latter case, var2 must contain an instance of var1's class or a class derived from var1.

Syntax 3: Associate a product object with a variable

Set var = Bind [ prodClass ] ( objectName )

Elements

var

A Variant variable, an object of prodClass, or any variable element that accepts an object reference, such as an element of an array, list, or user-defined data type.

Bind

The Bind keyword associates objectName with var. The association is made by name, and is valid until any of the following conditions is true:

  • var is out of scope.
  • objectName no longer exists.
  • var is set to another value.

Note that you should not use Bind to associate a Notes® object with a variable. Notes® implicitly binds its supporting objects.

prodClass

Optional. The product class of the object objectName. If prodClass is not specified, LotusScript® assumes that objectName is of the same class as var. If var is a Variant, you must include prodClass.

objectName

A string specifying the name and, optionally, the path of the product object of class prodClass.

The form of this string is product-specific. For example, the product object name might have the form "ApplicationWindowName\ObjectName." Refer to your HCL oftware documentation for information about specifying product object names.

Usage

The Set statement is the object reference assignment statement. It is parallel to the Let statement, the general assignment statement for variables of all types except object reference variables.

When you use the user interface, rather than a script, to create a product object, some HCL products implicitly declare the name you (or the product) have assigned the object as an object reference variable and bind it to the object. This allows you to use the object name in scripts without explicitly declaring a variable and binding it to the object.

To test an object reference variable for the NOTHING value, use the Is operator.

Example