Sub statement (LotusScript® Language)

Defines a sub.

Syntax

[ Static ] [ Public | Private ] Sub subName [ ( [ argList ] ) ]

[ statements ]

End Sub

Elements

Static

Optional. Directs LotusScript® to save the values of the sub's local variables between calls to the sub.

Public | Private

Optional. Public specifies that the sub is visible outside the scope (module or class) where the sub is defined, as long as this module is loaded. Private specifies that the sub is visible only within the current scope.

A sub in module scope is Private by default; a sub in class scope is Public by default.

subName

The sub name. The names Delete, Initialize, New, and Terminated are specialized. Use these names only as described in the topics Sub Delete, Sub Initialize, Sub New, and Sub Terminate.

argList

Optional. A comma-separated list of declarations for arguments to be passed to this sub when it is called.

The syntax for each argument declaration is:

ByVal argument [ ( ) | List ] [ As dataType ]

ByVal specifies that argument is passed by value: that is, the value assigned to argument is a copy of the value specified in the sub call, rather than a reference to the original value.

argument () is an array variable. argument List identifies argument as a list variable. Otherwise, argument can be a variable of any of the other data types that LotusScript® supports.

As dataType specifies the variable's data type. You can omit this clause and use a data type suffix character to declare the variable as one of the scalar data types. If you omit this clause and argument doesn't end in a data type suffix character (and isn't covered by an existing Deftype statement), LotusScript® assigns it the Variant data type.

Enclose the entire list of argument declarations in parentheses.

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).

Arrays, lists, type instances, and objects can't be passed by value as arguments. They must be passed by reference.

A sub does not return a value.

A sub can be called in either of these two forms:

subName arg1, arg2, ...

Call subName (arg1, arg2, ...)

A sub definition can't contain the definition of another procedure (a function, sub, or property).

A sub member of a class cannot be declared Static.

You can exit a sub using an Exit Sub statement.

Your HCL software application can provide special named subs for use in your scripts; see the product documentation for more information.

Example