Function libraries

We created some repetitive tasks as functions. Now we want to use the same functions in another script. Is there a way to create a function library and call functions from there to multiple scripts?

IMP: we are running in Linux environment.

Any help is very much appreciated, since we are running a trial now with a limited time window.


If you make each handler (command or function) its own script, then it’s very easy to call that handler just by using the name of the script. If you have a suite of these auxiliary handlers, then you can add them to any other suite or script either via the Helper mechanism, or by adding the suite directly into a script’s scope in code:

set the initialSuites to (“myAuxiliaryFunctions.suite”)

after which you can refer to any script in the specified suite as though it were in the current suite.

If you decided to create a script with many handlers in it, then you have to either reference those handlers via the script, e.g.:

run myHelper’s helpfulCommand

or you can add that script and its handlers into the scope of the executing script with a command of the form:

start using myHelper

after which you can just call the commands and functions in myHelper directly as though they were defined directly in the current script. If there is a drawback to this approach it’s that if you want to use these functions in many suites, then you will need to combine the techniques of adding suites and adding scripts in order to provide access to your helper functions in other suites.