Using variables
Variables provide a temporary location for storing data, which can then be accessed from any
context in the file. You can declare variables in:
Variables are not available outside the file in which they are declared, and one user’s variables are not available to other users. If you need data to be available to other files or to multiple users, use a field (without global storage) instead of a variable.
When you declare a variable, you can specify its scope by adding a prefix before the variable name.
Scope | Prefix | Example | Availability |
Let function | None | variablename | Only within the Let function where it is declared |
local | $ | $variablename | Only within the script where it is declared; cleared when the script ends |
global | $$ | $$variablename | Anywhere within the file where it is declared; cleared when the file is closed |
Local and global variables (or even two local variables in different scripts) can have the same name but they are treated as different variables and can store different values.
You can use variables in:
•calculations
•scripts
Repetitions in variables
Variables can include an optional repetition number that appears in brackets [ ] immediately after the variable name. For example, the following returns 111:
Let ( [
$var[1] = 1;
$var[2] = 10;
$var[3] = 100
];
$var[1] + $var[2] + $var[3] )
Repetitions in variables are not supported in:
•merge variables
•file paths
•find requests
Notes
•Variables are not supported in file paths that are stored in container fields.
•The data type of a variable is determined dynamically based on the assigned data.