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 execution. Constants can represent information that is often referenced within a task or data that can 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 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 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 commonly used and can change over time, such as user names, file locations, or email addresses. A constant name/value is pre-defined for a particular system. For example, you can create a constant named AdminEmail and assign the network administrator 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 want to deploy the task to a remote Automate Desktop client (or Runtime) you can 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 can 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 using Options > System Settings > Constants tab of the Task Administrator.

To create a new constant

  1. Click 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. Click OK.

To remove an existing constant

  1. From the list, select the desired constant.

  2. Click Remove.

NOTE: Before removing a constant, ensure you remove any references to it in your tasks.

To modify an existing constant

  1. From the list, select the desired constant.

  2. Click Modify.

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

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

  5. Click Apply.

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

Using constants

Similar to variables, constants can be used in any Automate Desktop step parameter by specifying the name of the constant surrounded by percent (%) 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 can be designed on one machine and run on others - either by exporting and importing or by deploying a task using remote administration. Because of this, sometimes it is necessary to specify a path to a file or any other piece of information that might 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.