Call statement (LotusScript® Language)

Calls a LotusScript® sub or function.

Syntax 1

Call subOrFunction [ ( [ argList ] ) ]

Syntax 2

subOrFunction [ argList ]

Syntax 3

subOrFunction ( argPassedByVal )

Syntax 4 (functions only)

returnVal = function [ ( [ argList ] ) ]

Elements

subOrFunction

The name of the sub or function being called.

argList

A list of arguments, separated by commas, for the sub or function being called.

argPassedByVal

A single argument to be passed by value to the sub or function being called.

function

The name of the function being called.

returnVal

The assignment variable containing the function's return value.

Usage

When you use the Call keyword, you must include parentheses around the argument list. If there are no arguments, the empty parentheses are optional.

When you omit the Call keyword, the following parenthesis rules apply:

  • For a sub or a function, do not use parentheses around the argument list (Syntax 2) unless you are passing a single argument by value to the sub or function (Syntax 3).
  • For a function within an expression, enclose the argument list (if there is one) in parentheses (Syntax 4).

Sub calls do not return a value.

LotusScript® uses a function's return value if the function call appears in an expression. The call can appear anywhere in an expression where the data type of the function's return value is legal. Function calls that use the Call keyword, however, do not return a value and cannot appear in an expression.

LotusScript® always uses the return value of a call to a built-in function. You must use its return value in an expression, and you cannot use the Call keyword.

Referencing a function that returns an array, list, or collection

If a function returns an array, list, or collection, a reference to the function can contain subscripts according to the following rules:

  • If the function has parameters, the first parenthesized list following the reference must be the argument list. A second parenthesized list is treated as a subscript list. For example, f1(1,2)(3) is a reference to a function f1 that has two parameters and returns a container.
  • If the function has no parameters and the return type is a variant or collection object, two parenthesized lists, but not one, can follow the reference. The first must be empty and the second is treated as a subscript list. For example, f1()(3) is a reference to a function f1 that contains no parameters but is a container.
  • If the function has no parameters and the return type is not a variant or collection object, any parenthesized list following the reference is an error, except that a single empty list is allowed. For example, f1() is a reference to a function f1 that contains no parameters and may or may not be a container; if f1 is a container, the reference is to the entire container.

Example