LOTUSSCRIPT LANGUAGE


Function statement
Example

Defines a function.

Syntax

[ Static ] [ Public | Private ] Function functionName [ ( [ paramList ] ) ] [ As returnType ]

[ statements ]

End Function

Elements

Static


Public | Private
functionName
paramList
returnType
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.

To return a value from a function, assign a value to functionName within the body of the function definition (see the example).

If you assign an array to functionName, you cannot refer to an element of functionName within the body of the function; such a reference will be taken as a recursive call of the function. To refer to an element of functionName, assign functionName to a variant variable and index the element there.

A function returns a value; a sub does not. To use the value returned by a function, put the function call anywhere in an expression where a value of the data type returned by the function is legal.

You don't have to use the value returned by a function defined by the Function statement. (The value returned by a built-in function must be used.) To call a function without using the return value, use the Call statement.

A function definition cannot contain another function or sub definition, or a property definition.

A function member of a class cannot be declared Static.

You can exit a function using an Exit Function statement.

Note If you're using a 32-bit version of Windows, an integer has four bytes; use the short integer (two bytes) to correspond to the LotusScript Integer when passing data to LotusScript. This note applies to Windows platforms only.

Example
See Also