User Guide > Objects > Working with Objects > Usage

Using Predefined Variables

There are some points that require particular consideration when you use or replace variables.

Script

Variables that are used in scripts are replaced before the script is processed.

Predefined variables are quite similar to script variables. Their values can be read and used at any point. Predefined variables, however, are not created and they have a predefined name. Thus, they cannot be modified in the script and any attempt to do so will result in an error:

:SET&$CLIENT# = 17

As opposed to attributes, AE Script does not support the use of variables for Variable object values. Therefore, they are not available in the Variable picker. Use the script element GET_VAR to access Variable objects via script.

Using the script element :PUT_ATT to write a predefined variable to an attribute has the effect that it will be inserted without any changes and replaced only after the script has been processed. If a script modifies an attribute that represents a predefined variable used in the object, the new value is used for the replacement. In the script, the new variable value is applied starting with the modifying scripting line.

Example:
Job with the following attributes:
Internal account: Acc1
Archive key 1: &$INT_ACCOUNT#
This scripting line writes the predefined variable for the agent name to the attribute "Internal account":
:PUT_ATT INT_ACCOUNT = &$HOST#
Variables are replaced after the script has been processed. The internal account and Archive key 1 obtain the agent's name as their value.

Variables for attributes that are used in the script have no value at the position at which they include predefined variables themselves.

Using GET_ATT to read an attribute that includes predefined variables has the effect that the value is returned without any replacements being made.

Variables used within JCL or script literals are not replaced. 

The script editor's auto-completion function lists the variables that are already in use.

Note that numerical predefined variables are automatically formatted to 16 digits if they have been enclosed in parentheses () in the script element :SET

For example: The original 4-digit format of the client is lost. The script variable &CLNTNR# obtains a value such as "0000000000008100".

:SET &CLNTNR# = (&$CLIENT#)

Attributes

The values of predefined variables that are used in attributes are replaced after the script has been processed. If the variable name is invalid it cannot be replaced. Automic recommends checking the correct syntax and the object type or using the Variable picker to insert the variables.

Variables that are used in their own attribute are not replaced. The same is true for two attributes that refer to each other through variables.

Any other combination of object attributes is possible.

Example:
Attributes of a Windows job:
Working directory: C:\temp\work_&$date_yyyymmdd#\
Command: UCYBDBld -B -C0001 -X&$WORK_DIR#\UC_DATA.TXT -EREPLACE
The content of the Command field depends on the working directory which includes a system value variable. First, the date is entered in the "working directory" field and then the variable is replaced by the corresponding content in the "Command" attribute.

If the replaced attribute value exceeds the defined maximum length, it will be truncated at the field end.

In attributes, you can also use predefined variables for Variable object values.

Predefined variables for system and object values can also be used as part of a variable placeholder. Example: {VARA&$CLIENT#}
This is not possible the other way round because system and object values are inserted before variable values.


See also:

About Predefined Variables
"Variable Picker" Dialog
List of Predefined Variables for System and Object Values