Type statement (LotusScript® Language)

Defines a user-defined data type consisting of one or more members.

Syntax

[ Public | Private ] Type typeName

member declarations

End Type

Elements

Public | Private

Optional. Public specifies that the user-defined data type is visible outside the module where it is defined, as long as that module is loaded. Private specifies that the user-defined data type is visible only within the module where it is declared.

A type is Private by default.

typeName

The name of the type.

member declarations

Declarations for the members of the type. There must be at least one declaration in the type; the declarations cannot include Const statements.

Usage

Defining types

A Type statement is valid only at module level.

The word Object is illegal as a type name.

Declaring type members

A member is a variable declaration without the Dim, Private, Public, or Static keywords. A member cannot be declared to be Private, Public, or Static; it's automatically Public.

Each member statement declares one variable.

The data type of a member can be any of the scalar data types, a Variant, a fixed array, or any other user-defined data type. It cannot be the same data type as that being defined by the current Type statement.

A member declared as Variant can hold any scalar value, an array (fixed or dynamic), a list, or a reference to a user-defined object, a product object, or an OLE Automation object. The following rules apply to type instances that have Variant members containing arrays, lists, or objects:

  • You cannot assign a type instance containing a dynamic array or a list to another type instance.
  • You cannot use the Put statement to write data to a file from a type instance containing a dynamic array, a list, or an object.
  • When you assign a type instance containing an object to another type instance, LotusScript® increments the internal reference count of the object.

A member can use any LotusScript® keyword, except Rem, as its name.

Declaring a type variable

A user-defined data type name is used in variable declarations in the same way as any other data type. The common variable declaration has the syntax:

Dim varName As typeName

This declaration declares a variable of the type typeName and initializes the members of the new variable. The initial values of the members are the same as for ordinary variables:

  • Numeric data types (Boolean, Byte, Integer, Long, Single, Double, Currency): 0
  • Variants: EMPTY
  • Strings, fixed-length: A string filled with the Null character Chr(0)
  • Strings, variable-length: The empty string ("")

If a member is itself a user-defined data type, then it is assigned initial values in the same manner.

Referring to type members

Refer to members of a type using dot notation, in the form varName.memberName. Spaces, tabs, and newline characters are legal on both sides of the period (after varName and before memberName).

Member references can also include array subscripts if the member is an array.

Example