Script Library

Script Libraries allow you to create libraries of commonly used code or data that can be shared among scripts in adTempus. For example, suppose that you have several jobs where you need to pass the current date as one of the command-line parameters to the scheduled program (but the other parameters are different for each job, so you cannot use a single Shared Script for all of the jobs).

Rather than repeating the necessary formatting code in the command-line script for each task, you can create a function in a Script Library, and then reference the library from the scripts. This in turn allows you to call the functions and subroutines defined in that library.

A Script Library can contain any code or data declarations that are valid for the scripting language you specify for the library.

InlineFunctions Library

The predefined library named "InlineFunctions" contains Inline Function definitions and cannot be deleted. Functions in this library can be used as inline functions, and can also be referenced by scripts just like regular script libraries.

Script Library Code and Namespaces

The various scripting languages all handle namespaces slightly differently, and this may affect the way you are able to define and call code in your script Library.

WSH Scripting Languages

The Windows Scripting Host (WSH) languages (VBScript, JScript, and other WSH-compatible languages) do not support multiple namespaces. As a result, all of the code for a script and for all of the libraries it references end up in the same namespace. You therefore must take care that you do not have variables or procedures in different libraries that have the same name, if those libraries will be used by the same script.

VB.NET

All VB.NET script and library code used by adTempus is placed in the global namespace. Code for each Script Library must be contained by a public Module (by default the Script Library Editor will set the module name to match the library name, but this is not required).

Therefore you may have variables and procedures in different libraries that have the same name, but you may need to qualify a the variable or procedure name using the library name when you use it in a script.

For example, you have created a Script Library named "MyLibrary," and the module defined in it is also named "MyLibrary." Within that module you have a public function named "MyFunction."

When you reference this library from a script, you can call your function using either MyLibrary.MyFunction or MyFunction.

However, if you create a second library that also contains a function named "MyFunction," and both libraries are referenced by your script, "MyFunction" by itself is ambiguous, and you will need to call MyLibrary.MyFunction.

C#

All C# scripts and libraries by are created to use the "UserScript" namespace. You can change the namespace if you wish, and make references across namespaces as necessary. The "adTempus" object used for interaction with adTempus is always in the "UserScript" namespace.

Windows PowerShell

Any function definitions or commands you place in a PowerShell script library are added to the PowerShell runspace before your script is executed, exactly as if they had been included in your script.