Skip to main content
Skip table of contents

Functions

A function is a block of code that is declared once, with a reference name.

This code can then be run on demand by simply invoking its name.

It differs from Loop, While, If, Execute, ExecuteVar and all other utilities that enable the execution of sub-scripts by the scope of its own variables and lists.

An automation List or Variable is always global: once set, it is available for writing and reading in all parts of the script (even from/to sub scripts invoked from an Execute action tag, or OnError/OnExit Execute directives).

NB: variables are automatically instantiated when used; e.g. if a variable was never declared with SetVar, and then used in a tag, it becomes part of the set of variables, with an empty value.

When a variable or List is declared within a function, it is only available inside the function scope and below. If function F1 calls function F2, variables declared in F1 are available for read/write in F2.

Once the execution of a function is complete, its local variables and lists are erased, and are not visible to the rest of the scipt.

NB: if variable V is declared in function F1, and then read/written in the main script, it becomes a regular, global variable. The next call to F1 will not make V local to F1.

Global lists and variables (declared outside the function) can be modified inside the function: after function completion, their contents are not restored to their pre-function call values.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.