Execute function and statement (LotusScript® Language)

Compiles and executes a text expression as a temporary module.

Statement Syntax

Execute text

Function Syntax

Execute ( text )



A string expression specifying the text to be compiled and executed.

Return value

The Execute function returns one of the following values:

  • The return code of an End statement, if one was executed.
  • Zero (0), if no End statement was executed, or if the executed End statement had no return value.


LotusScript® considers text a separate script, compiling and executing it as a temporary module that's unloaded as soon as execution finishes.

Variables declared in the calling script (where the Execute statement appears) are only accessible in the temporary module if they are declared Public. Both these Public variables, and variables declared Public in external modules used by the calling script, will be accessible automatically. To reference a local variable in the temporary module, use the CStr function to convert its value to a string, and then include the result in text.

Variables declared in the temporary module are not accessible outside of that script.

To delimit text that spans several lines or includes double-quote characters, use vertical bars (| |) or braces ({ }).

Any compilation error in the temporary module will be reported as a run-time error in the scope containing the Execute statement. Any run-time error in the temporary module will be reported as a run-time error within the scope of that module, not the scope containing the Execute statement. To handle run-time errors within the temporary module, use the On Error statement.

The Execute statement is not legal at the module level; you can use it only in procedures.

Note: In Notes®, if you modify a global variable in an Execute statement, the variable must be defined in the (Declarations) event for (Global), not the (Declarations) event for the object containing the script.