Understanding Variables


A best practice with automation is to separate the steps you perform from the data used by those steps. This allows you to easily alter that data later without searching through all your steps to make sure you have made the necessary changes. In AutoBloks, we accomplish this using Variables.

This tutorial builds on the Interacting with Elements tutorial. You are encouraged to complete or at least review that tutorial before beginning this one. If you do not have the files created during that tutorial, you will need to download those completed files to use for this tutorial.

What Are Variables?

A variable is simply a placeholder for some other value. In mathematics, you may have used variables to represent unknown values like in the expression 7 + x = 10. In software, variables are used to store and retrieve data. This allows software to work with values that may not even be known in advance. When performing a Google search, the search engine does not know your query until you type it. That value is then stored in a variable and referenced by the software.

Locker Analogy

A good way to understand variables is to think about them like a wall of lockers for your data. You can have multiple lockers, so you can store different pieces of data. Since all lockers look the same, you put a label on the door to each locker, so you can remember which data goes where. When you store data, you open the locker with the correct label and put your data inside. When you need to get the data back, you seek out the locker with the right label, open the door, and retrieve your data.

Each locker represents a variable and the label on the locker is the name assigned to the variable. When building automation, you can create variables to represent important data and then refer to each variable by name. When your automation is running, the placeholder represented by each variable will be replaced by the actual data that is stored in the variable at that time.