Constants

This article covers the following topics:

Constants Overview

Using Constants

Creating & Defining Constants

Overview


Like variables, constants are used to represent data in a task. However, unlike variables, constants have a fixed value which cannot be modified during a task's execution. Although a constant value is specified only once, the value can, however, be referenced multiple times within a task. The value of a constant is considered "global" which means that it is available to all tasks on the system. The elements of a constant consists of a name and a value. When you use a constant in a task step, AutoMate substitutes its assigned value during execution.

Constants are useful for assigning data that may be different from machine to machine, or data that is used often and may change over time, such as user names, file locations, or e-mail addresses. For example, you could create a constant named AdminEmail and assign the network administrator's email address as the value and use this constant in multiple tasks where you wanted to send an e-mail notification to the network administrator. If you wanted to deploy the task to a remote AutoMate client (or Runtime) physically located in another address that employs its own network administrator, you would create a constant of the same name at the other location and assign it the e-mail address of the other network administrator. If changes are maid to the e-mail address, you would simply change the value of the constant to match the new e-mail address.

Using Constants


Similar to variables, constants may be used in any AutoMate step parameter by specifying the name of the constant surrounded by percentage (%) signs. Using a constant instead of specifying a value multiple times in a task can simplify code maintenance. Additionally, constants can act to make tasks more portable, as they can easily pass on information to the task at runtime about the current environment.

AutoMate tasks may be designed on one machine and run on others - either by exporting and importing or by deploying a task via remote administration. Because of this, sometimes it is necessary to specify a path to a file or any other piece of information that may be different from machine to machine. It is impractical to design a separate task for each machine. For instances such as this, AutoMate allows the use of constants.

Creating & Defining Constants


Constants are local to each machine and are stored in the local machine settings of the registry in the AutoMate 9 key. Constants are created and defined via System -> Options -> Constants tab of the Task Administrator.

To create a new constant:

  1. From the System menu in the Task Administrator window, select Options.

  2. Click the Constants tab. The dialog box shown below appears:

  1. Click the Add button. A dialog titled AutoMate Constants appears as shown below:

  1. In the AutoMate Constants dialog box, enter a name and value for the constant. A constant name must begin with a letter, and contain only letters and numbers. You can also enter a comment for reference (the comment is optional and does not affect how the constant behaves).

  2. Click OK.

To remove an existing constant:

  1. Select the constant from the User defined constants list.

  2. Click Remove.

  3. Click OK.

NOTE: Before removing a constant, be sure you have removed any references to it in your tasks.

To modify an existing constant:

  1. Select the constant from the User defined constants list.

  2. Click Modify.

  3. In the AutoMate Constants dialog box, modify the name, value and comment relating to the constant.

  4. To disable a constant, clear the Enable check box.

  5. Click OK.

For complete instructions on how to create, define and modify constants, see Constants Settings.

See Also

Task Variables

Local Variables

Datasets

Configuring AutoMate