What are Constants?

Like variables, constants can be used to represent data in a task. However, unlike variables, constants have a fixed value which cannot be modified during a task's execution. Constants can represent information that is often referenced within a task or data that may be common to many tasks. This makes information portable and simple to update. The elements of a constant consists of a name and value. A constant's defined value is global, thus, are available to all tasks on a particular system.   When you use a constant in a task step, AutoMate substitutes its assigned value during execution. When you modify a constant's value, every occurrence of that value is updated across the system. The Constants properties page (available from Options -> System Settings -> Constants) lists all the user-defined constants in the system.

Constants are useful for assigning data that is used often and may change over time, such as user names, file locations, or e-mail addresses. A constant's name/value is pre-defined for a particular system, For example, you could create a constant named AdminEmail and assign the network administrator's email address as its value. This constant can be referenced 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) you would simply 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.

Creating & Defining Constants

Constants are local to each computer and are stored in the local machine settings of the registry in the AutoMate 8 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.

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.