Creating & Defining Constants
Like variables, constants are used to represent data in a task. However, unlike variables, constants have a fixed value and cannot be modified during a task's execution. 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 defined globally for each machine, and once defined, are available to all tasks on that machine.
Constants are useful for 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. You could use this constant in multiple tasks where you wanted to send an e-mail notification to the network administrator. If you wanted to run such a task at another location with a different network administrator, you would set up a constant of the same name at the other location and assign it whatever value you wanted. If the network administrator's e-mail address changed, you would simply change the value of the constant.
Constants can be created and defined from either the server or agent level which are located in two distinct locations within the SMC:
Server Level: Select the Options tab, navigate to Server Settings and double-click Constants.
Agent Level: Select the Agents tab, navigate to and double-click the desired task agent or agent group or right-click the task agent/agent group and select Properties from the right-click menu. Then double-click Constants.
To create and define a constant, see Constants Settings.
NOTE: To avoid conflicts with Basic key words, functions, or instruction, include distinguishing characters in the names of your constants. For example, you could start all constant names with CONST. Also, if you use many constants, you may want to use the names to categorize them. For example, you could begin all e-mail address constants with CONSTEMAIL and begin all file location constants with CONSTFILE.
Constant behavior varies depending on where it was created from.
Server Level Constants: Constants created from the Server level are accessible to all available Agents, thus are displayed along with the list of constants created from the Agent properties and appear in bold. Server created constants cannot be deleted or modified from the Agent properties. Server level constants appear in italic and associated with a unique icon.
Agent Level Constants: Constants created from the Agent properties of a specific agent can only be accessed by the Agent that the constant was created under. They can be edited or deleted only from that specific Agent as well. These constants are not recognized by the server and therefore, not populated in the server’s list of constants. Agent level constants appear non-italic and are associated with an "A" icon.
NOTE: All constants that appear grayed out specifies that the constant is disabled.
Constants may be used in any AutoMate BPA Server 9 step parameter by specifying the name of the constant surrounded by percent (%) signs. For example, if a constant named BackupFolder was initially created and given the value of an existing directory used to normally backup files to, in order to specify this directory as the destination in a 'Copy File' action, simply enter %BackupFolder% in the Destination parameter of this action.
From the properties dialog of an action, click inside any entry box then click the Insert Expression/Variable button which appears next to any entry box that accepts expressions.
From the Expression Builder window that appears, select the folder labeled Constants from the list of folders located in the bottom left pane (as shown below).
Double-click a selection from the list of the defined constants for the local machine that are populated in the bottom right pane. This populates the top pane with the selected item. The selected item will be automatically surrounded with percent signs upon insertion, therefore, there is no need to surround the item with percent signs at this point.
Click the Insert button to properly insert the constant and close the Expression Builder window. For further information, see Expression Builder.
Machine 1 has Microsoft Office installed in C:\OFFICE. Machine 2 has Microsoft Office installed in D:\MSO
On Machine 1, create a constant named ConstOfficeFolder with a value of C:\OFFICE
On Machine 2 create a constant named ConstOfficeFolder with a value of D:\MSO
Create a task containing a 'Run' action, designating %ConstOfficeFolder%\winword.exe in the Run parameter of this action's properties as the file to run.
The task can be run on either machine and will find the correct file.
↑ Top of Page