Bitfocus AS
logo
logo
Bitfocus AS
logo
logo
Sign upSign in

Loading...

Bitfocus

Subscribe to our newsletter

The latest news, articles, and resources, sent to your inbox.

FacebookInstagramGitHubYouTubeLinkedIn

Products

  • Buttons
  • Companion

Integrations

  • Supported Devices
  • Developer Community
  • Connection Development

Support

  • Support Overview
  • Documentation
  • Video Tutorials
  • Community Forum

Sales

  • Resellers & Integrators
  • Buttons Pricing

Updates

  • Case Studies
  • Events & Trade Shows
  • Press Releases
  • Product Updates
  • Webinars

Legal

  • Legal Overview
  • Privacy Policy
  • Buttons EULA
  • Terms & Cookie Policy

Company

  • About us
  • Press kit
  • Careers

© 2026 Bitfocus AS. All rights reserved.

Understand variable scope
Docs for
Overview
Getting started
What is Bitfocus Buttons?
Install Buttons and get started
Manage your Buttons license
Activate Buttons offline
Find your way around Buttons
Create your first backup
Add an ATEM connection
Choose a control method
Choose an installation path
Install Buttons on Debian or Ubuntu
Understand HA clustering
Kubernetes HA
Update or remove Buttons
Positions
Understand positions
Create a position
Add controls and sections to a position
Create your first button
Use a connection's presets
Build more capable button actions
Add more feedback to a button
Organize controls in a section
Shift Section
Organize controls with a Folder Section
Add a Popover Section
Build and reuse a Shared Section
Build a Router Section
Understand Custom Routers
Custom Router panel
Surfaces
Surface compatibility
Add and attach a surface
Device orientation
Connections
Update a connection's module safely
Monitor and troubleshoot a connection
Router integrations
VideoHub and AJA KUMO
Utah Scientific BPS
Generic SW-P-08
Nevion VideoIPath
Arkona BLADE//runner
Routing
Physical routing
Configure ports and labels
Take a physical route
Understand route status
Topology graph
Routing Presets
Get started with virtual routing
Configure Nested Shapes
Reverse routing
Tielines
Routing Projects
Routing settings
Troubleshoot a route
Tally
Understand the Tally system
Send ATEM tally and labels to a UMD
Interpret Active Tally state
TSL/UMD connections
Diagnose tally problems
NMOS
Understand NMOS in Buttons
Connect Buttons to an NMOS Registry
Built-in Registry Server
Configure NMOS connections
Discover and adopt
Browse the NMOS inventory
Manage NMOS multicast addresses
Diagnose NMOS problems
Understand Cuelists
Build a Cuelist
Read and advance a running Cuelist
Control a Cuelist from a Position
Workflows
Understand workflows
Build your first workflow
Reuse a group of workflow nodes safely
Troubleshoot a workflow
Recipes
Sequence a timed automation
Call an HTTP endpoint from a workflow
REST endpoint
Use variables
Understand variable scope
Understand nested variables
Update expressions for v1.8
Plan and use Tags
Access
Create and manage users
Create roles and assign permissions
Grant access to specific resources
Show different controls by role
Sessions
Set up PIN and NFC sign-in
SSO
Get started with SSO
Connect a generic OIDC provider
Connect LDAP or Active Directory
Map identity claims to roles
Secure a Buttons deployment
Integrations
External control
Connect to Bitfocus Listener
USB Relay
Install USB Relay on Windows
Install USB Relay on macOS
Install USB Relay on Linux
Install USB Relay on a Raspberry Pi
Get started with the Control API
Secure and monitor the Control API
Control API reference
API reference
Administration
Enable and manage installable features
Services and health
Configure and monitor scheduled backups
Restore a backup and verify it
Export or import Buttons configuration
Store and rotate connection secrets
Replace the HTTPS certificate
HA backup and recovery
Settings
Collect support information
Reference
Glossary
Button Inspector reference
Network ports reference
Expressions
Internal actions reference
Routing Presets panel reference
Startup configuration reference
Workflow nodes
Connection workflow nodes
Workflow workflow nodes
Internal workflow nodes
Position workflow nodes
API workflow nodes
Utility workflow nodes

Loading...

Previous
← Use variables
Next
Understand nested variables →
Contact support →
You are viewing documentation for Buttons 1.8.See the docs for Buttons 1.6
Buttons/Variables/Understand variable scope

Understand variable scope

A variable can help you store a piece of information once and reuse it (a name, a count, a reference to a connection) anywhere Buttons lets you reference variables. Which variables you can see and use at a given point depends on scope: where a variable was defined determines where it's visible. Understanding scope up front avoids the most common variable mistake: two variables with the same name that turn out to be in different scopes, and don't refer to the same value at all.

Variable types#

A variable holds one of these types:
  • String: text. Can be empty.
  • Number: for counting or math. Can't be empty.
  • Boolean: true or false only. Can't be empty.
  • Connection: a reference to one of your configured connections, used to swap which connection a control targets at runtime rather than fixing it permanently.
  • Routing Endpoint: a reference to a routing port or bundle, the routing equivalent of a Connection variable.
  • Feedback: a read-only value driven directly by a connection's own feedback, rather than something you set yourself. Defining one means picking both the feedback and, if that feedback takes its own options (such as which input to watch), those options too: set once when you create the variable, not per position.

The scopes, from narrowest to widest#

Self (inside one element only)
→ Parent (the element's own parent, exposed to it)
→ Position (global definition, one value per position)
→ Workflow / Connection (global, one shared value everywhere)

Self variables#

A Self variable lives inside the specific button, section, or similar element where you define it. It isn't visible anywhere else, not even to a sibling copy of the exact same button. Two separate buttons can each have a Self variable with the same name and different values without conflicting, because neither can see the other's.
Reference a Self variable as $(self.state.name).

Parent variables#

A Parent variable is defined inside an element, but it's exposed as a Self variable of that element's parent instead of the element itself. This is how a button placed inside a section can expose a value the section itself can then read as its own Self variable: the naming describes the relationship, not a separate mechanism.
Reference a Parent variable as $(parent.state.name).

Position variables#

A Position Variable's definition is global (creating one makes it available in every position), but its value is set independently per position. This means the variable's name and type are shared everywhere, while what it actually holds depends on which position you're looking at.
A Position Variable can hold a Connection-type value, which is what lets a single position swap which connection its buttons actually control: set the variable to a different connection, and every action using it follows, without editing each button individually.
Reference a Position Variable as $(position.state.name).
Change a Position Variable's value with the Set Position Variable Internal Action.

Workflow variables#

A Workflow Variable is global for both reading and writing, from anywhere in Buttons, not scoped to the workflow that created it. Creating one requires a Workflow, since that's where the variable is defined and typed, but once created it's just as visible everywhere as a Connection Variable is.
Change a Workflow Variable's value with the Set Workflow Variable Internal Action.

Connection variables#

A Connection Variable is supplied by a connection itself: Buttons doesn't let one connection see or change another's variables directly, but a connection's own actions and feedbacks can manipulate its variables, and other parts of Buttons can read them. Each connection has its own Variable Key, set on its Config tab; the full reference combines that key with the variable's own name, such as $(MyAtem.device_ip).
If you run more than one connection using the same module, give each a distinct Variable Key, otherwise you can't tell their variables apart by name.

Choosing names deliberately#

No two variables visible in the same place can share a name, but variables in different scopes can, safely, precisely because they're never visible together. Use Variable Scope itself as your main tool for avoiding collisions: keep a value in Self or Parent scope unless it genuinely needs to be seen from elsewhere, and reach for Position or Workflow scope only once something actually needs to be global.

Where to go next#

  • Use variables in controls and expressions.
  • Understand nested variables.

Was this helpful?

Was this helpful?

0 of 0 users found this page helpful