LOTUSSCRIPT LANGUAGE


Defining functions
When you define a function, you provide the function's signature and the set of statements that are to be executed when the application calls the function.

The syntax for defining a function is:

[ Static ] [ Public | Private ] Function functionName [ ( parameters ) ] [ As dataType ]


ElementDescription
StaticDeclares variables defined within the function to be static by default. Static variables retain their values (rather than going out of existence) between calls to the function while the module in which it is defined remains loaded.
Public, PrivateWhen you declare a function at module level, Public lets the application refer to the function outside the module in which the function is defined, as long as that module is loaded. Private means that the function is available only within the module in which it is defined. When you declare a function inside the definition of a user-defined class, Public means that the function is available outside the class definition. Private means that the function is only available within the class definition. By default, functions defined at module level are Private, and functions defined within a class are Public.
functionNameThe name of the function, which can end in a LotusScript data type suffixes (%, &, !, #, @, and $). These determine the data type of the functionfs return value. You can append a data type suffix to a function name when you declare the function only if you do not include the As dataType clause in the declaration.
parameterListA comma-delimited list of the functionfs formal parameters (if any), enclosed in parentheses. (The list can be empty.) This list declares the variables for which the function 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. ByVal is optional.

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 canft pass an array, a list, an object reference, or a user-defined data type structure by value.

As dataType specifies the variablefs data type. You can omit this clause and use a data type suffix to declare the variable as one of the scalar data types. If you omit this clause and paramName doesnft end in a data type suffix (and isnft covered by an existing Deftype statement), its data type is Variant.

As dataTypeSpecifies the data type of the functionfs return value. A function can return a scalar value, a Variant, or an object reference. If you include this clause, functionName cannot end in a data type suffix. If you omit this clause and functionName doesnft end in a data type suffix (and isnft covered by an existing Deftype statement), the functionfs return value is Variant.
Declaring functions
In releases of LotusScript before 4.0, there were situations where it was required to declare functions before they were referenced. In LotusScript 4.0, this is no longer needed and forward declarations of LotusScript functions are accepted and ignored.

The syntax for declaring a function is:

Declare [ Static ] [ Public | Private ] Function functionName
[ ( parameterList ) ] [ As dataType ]

See Also