Constants

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 Desktop 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 email 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 email notification to the network administrator. If you wanted to deploy the task to a remote Automate Desktop client (or Runtime) you would simply create a constant of the same name at the other location and assign it the email address of the other network administrator. If changes are made to the email address, you would simply change the value of the constant to match the new email address.

Creating & defining constants

Constants are local to each computer and are stored in the local machine settings of the registry in the Automate Desktop key. Constants are created and defined by way of Options > System Settings > Constants tab of the Task Administrator.

To create a new constant

  1. Select New.
  2. 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).
  3. Select OK.

To remove an existing constant

  1. From the list, select the desired constant.

  2. Select Remove.

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

To modify an existing constant

  1. From the list, select the desired constant.

  2. Select Modify.

  3. Make any desired changes to the name, value, and comment relating to the constant.

  4. To disable a constant, clear the Enable checkbox.

  5. Select Apply.

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 Desktop 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 Desktop tasks may be designed on one machine and run on others - either by exporting and importing or by deploying a task by way of 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 Desktop allows the use of constants.