LOTUSSCRIPT LANGUAGE


Defining subs
The syntax for defining a sub is

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


End Sub

ElementDescription
Public, PrivateWhen you declare a sub at module level, Public lets the application refer to the sub outside the module in which it is defined, as long as that module is loaded. Private means the sub is available only within the module in which it is defined. When you declare a sub inside the definition of a user-defined class, Public means that the sub is available outside the class definition. Private means that the sub is only available within the class definition. By default, subs defined at module level are Private, and subs defined within a class are Public.
StaticDeclares variables defined within the sub to be static by default. Static variables retain their values (rather than going out of existence) between calls to the sub while the module in which it is defined remains loaded.
subNameThe name of the sub.
parameterListA comma-delimited list of the sub’s formal parameters (if any), enclosed in parentheses. (The list can be empty.) This list declares the variables for which the sub expects to be passed values when it is called. Each member of the list has the following form:

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

ByVal means that paramName is passed by value: that is, the value assigned to paramName is a local copy of a value in memory rather than a pointer to that value. paramName() is an array variable; List identifies paramName as a list variable; otherwise, paramName can be a variable of any of the other data types that LotusScript supports. You can’t pass an array, a list, an object reference, or a user-defined data type structure by value. 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 paramName doesn’t end in a data type suffix character (and isn’t covered by an existing Deftype statement), its data type is Variant.


Declaring a sub

In releases of LotusScript before 4.0, there were situations where it was required to declare subs before they were referenced. In LotusScript 4.0, this is no longer needed and forward declarations of LotusScript subs are accepted and ignored.

The syntax for declaring a sub is:

Declare [ Public | Private ] [ Static ] Sub subName [ ( parameters ) ]

See Also