A function is a named procedure that returns a single value. LotusScript® provides a set of built-in functions that you can use to perform a variety of common numeric, date/time, string, data-conversion, and value-testing operations.

LotusScript® also lets you create your own functions. You define a function by specifying a series of one or more statements that are executed as a block when the application calls the function. You enclose these statements between the function signature and the End Function statement.

A function signature specifies the function name, its scope, the data types of the values that it expects the application to pass it (if any), the lifetime of the variables that it defines (if any), and the data type of the value it returns to the application.

The statements that comprise the body of a function can include the following:

  • Variable declarations
  • Assignment statements (including statements that assign values to the function itself)
  • Calls to built-in functions
  • Calls to user-defined procedures and functions (including calls to the function itself)
  • Looping and branching statements (including Exit Function and End, which cause execution of the function to terminate before reaching the block terminator)
  • Statements for performing standard file operations and for communicating with the end user

Statements and directives that declare or define a function, sub, property, or user-defined data type or class are not allowed within the body of a function, including:

  • Declare
  • Function
  • Sub
  • Property Get
  • Property Set

Additionally, you may not include the following statements in the body of a function:

  • Option
  • Use statements
  • UseLSX statements