LOTUSSCRIPT LANGUAGE
Defines a function.
Syntax
[ Static ] [ Public | Private ] Function functionName [ ( [ paramList ] ) ] [ As returnType ]
[ statements ]
End Function
Elements
Static
A function in module scope is Private by default; a function in class scope is Public by default.
The syntax for each parameter declaration is:
[ ByVal ] parameter [ ( ) | List ] [ As type ]
parameter() is an array variable. parameter List identifies parameter as a list variable. Otherwise, parameter 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 append a data type suffix character to parameter to declare the variable as one of the scalar data types. If you omit this clause and parameter has no data type suffix character appended (and isn't covered by an existing Deftype statement), its data type is Variant.
returnType can be any of the scalar data types, or Variant, or a class name.
If As returnType is not specified, the function name's data type suffix character determines the return value's type. Do not specify both a returnType and a data type suffix character; LotusScript treats that as an error.
If you omit returnType and the function name has no data type suffix character appended, the function returns a value either of data type Variant or of the data type specified by a Deftype statement.
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