Variables - Overview
A variable is a named storage location that can contain data which, if needed, may be modified during task execution. In this manner, variables can be used to represent and store dynamic data that may be different each time the task is run. Each variable has a name that uniquely identifies it. Variables can be used to represent data in a task that may be different from system to system.
How to Create a Variable
Automate's 'Create Variable' action generates a variable which can be used to store dynamic values for utilization in any step of the task or any subtasks started with the 'Start Task' action. The developer can enter a value to the variable during creation or the value field can be left blank. Instead, variables can be set with a value using the 'Set Variable' action, which adds or changes the contents of an already existing variable or by certain available actions that support populating variables, such as the 'Input Box' action. This action displays an input box allowing the user to enter a value which is saved to the variable specified.
How Variables Are Used
All variables to be passed into Automate's scripting language, either explicitly through the use of a 'BASIC script' action or implicitly through the use an expression, need to always be created first. In other words, an initial step within the beginning of a task needs to create the variable before it can be recognized / utilized by any other steps during execution. To capture the current value of an initially created variable in any action parameter or step, simply surround the variable name with percentage (%) signs. The percentage signs at the beginning and end of the variable name inform Automate that the text in-between the "%" is an expression and should not be taken literally. Instead, it is replaced with the current contents of that variable at runtime.
Constants - Overview
A Constant is a variable whose value cannot be changed once it is initially bound to a value. In other words, a constant cannot be assigned to or 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.
How to Create Constants
Before constants can be used, they must be created and configured in a particular location. Because constants are considered "global" they are configured from within the Task Administrator under 'System' -> 'Options' -> 'Constants' tab rather than within the steps of a particular task. In this manner, constants can be stored properly in the Automate 6 key of the local machine's registry. When creating a constant from the 'Constants' tab, the constant's view is separated into three columns:
1. Name - the name of the constant. This is how the constant is referred to in Automate tasks.
2. Value - the value that is contained within the constant.
3. Comment - a description for the constant. This is used only in the Constant Options view as reference, and has no bearing on the constant itself.
Like variables, a constant name must begin with a letter, and contain only letters and numbers. Note that if removing a constant, you must make certain to remove or modify the steps of your tasks that referenced that constant. Tasks that refer to a constant that is not present on the system will fail when run.
How to Use 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.
It is important to remember not to use percentage signs when specifying the name of a variable constant to populate. Percentage signs are only used to get the current value of a variable or constant. Additionally, make certain that variable or constant names used do not conflict with a BASIC keyword, function or instruction. A common way to avoid this is to insert your own text to the beginning of all variable / constant names (e.g. "The" or "My"). Therefore, "Date" (which is a BASIC keyword) becomes "TheDate" or "MyDate," thus avoiding any name conflicts.
Applies To: Automate 5, Automate 6
Still have questions? We can help. Submit a case to Technical Support.