Managing Variables
Variables are the "memory" of your automation. In DS Studio, they are used to store multiple types of data that can change during the execution of a flow. Whether you are controlling how many times a loop executes or saving a product's price for a later calculation, variables are the essential containers for your data.
🏗️ Creating Variables
DS Studio provides several flexible ways to manage variables. While you can create them in multiple panels, we recommend using the Data Manager for the most centralized experience.
1. From the Data Manager
Open the Data Manager, navigate to the Variables panel, and select the Create Variable line. Here you can configure the name, type, scope, and default value.
2. Inline Creation (Ctrl+K) ⚡
While editing an activity in the Designer or the Properties panel:
- Click into an input field and press Ctrl+K.
- The Set Var field appears. Type your variable name and press Enter.
- Variables created this way automatically inherit the type required by the activity (e.g., creating a variable in a Write Range field sets it to
DataTable).
3. From Expressions
Select a part of an existing expression in an activity field and press Ctrl+K. The variable will be created and automatically mapped to that portion of the expression.
4. Auto-generated Outputs
If the Auto-generate Activity Outputs setting is enabled, DS Studio automatically populates output fields with generated variables. These appear in the Data Manager and can be renamed or modified as needed.
🧬 Variable Types
Every variable is Statically Typed, meaning it can only hold data that matches its defined type.
| Type | Description |
|---|---|
| Boolean | Stores true or false for decision-making. |
| Int32 | Stores numeric integers (e.g., 10, -5). |
| String | Stores text. Note: All strings must be wrapped in quotation marks ("John Doe"). |
| DataTable | Stores information in rows and columns, similar to a spreadsheet. |
| Object | A universal type that can store any data; use when high flexibility is needed. |
| Array [T] | Enables you to store multiple values of the same type. |
If a specific type is not in the default list, select Browse for Types from the dropdown. You can search the entire .NET library (e.g., searching "excel" to find specific interop classes).
🌐 Understanding Variable Scope
Scope refers to the reach or visibility of a variable. Think of scopes as Sets: a sequence can access its own variables and those of its parents, but it cannot see variables inside its "children."
The "Set Theory" Logic
As shown in the example below, Sequence B is nested inside Sequence A.
- Sequence B has access to all variables in the set:
{n, p, x, y}. - Sequence A only has access to its own set:
{n, p}.
Sequence A {
variables = n, p // Visible to A and B
Sequence B {
variables = x, y // Visible ONLY to B
// Accesses: n, p, x, y
}
// Accesses: n, p (x and y are out of scope here)
}