## Viewing Variables

The Variables view allows manipulation of project variables and the variable hierarchy used in the source code. For example, you can change the variable format, change a variable value, add watch expressions, or add global variables.

Figure 1 shows the Variables view with Show Type Names option enabled. The default view shows the variables list and include the Name and Value for all the variables within scope. In addition, when you select a variable its value is also shown in a different pane within the view.

Figure 1 - Variables view

### Variables view toolbar icons

The following commands appear on the Variables view toolbar:

Item | Icons | Explanation
--- | --- | ---
Show Type Names |  | Toggles the display of type names in the Variables view.
Show Logical Structure |  | Not available in C/C++ yet.
Collapse All |  | Collapses all expanded variables into the top level.
Add Global Variables |  | Click to open the Global Variables dialog where you can select one or more global variables to display in the Variables view. Global variables appear at the top of the variables list.
Remove Selected Global Variables |  | Click to remove all currently selected global variables from the variables list.
Remove All Global Variables |  | Click to remove all global variables from the variables list.
View Menu |  | Enables you to modifiy the Layout to change the view orientation between: horizontal, vertical, or variables pane only and customize the columns shown in the view. In addition, use Show All Variables to toggle between showing only those variables that are in scope and live or show all local variables, even if redundant. With this option on you will see all of the variables including the multiple defined variables like “i” for your loops and ones that may no longer have accurate values.

### Variables view context menu options

Right-click in the Variables view to access the commands on the Variables view context menu.

Figure 2. Variables view context menu commands

The commands include:

Item | Explanation
--- | ---
Select All | Selects all the variables shown in the Variables view.
Copy Variables | Copies the selected variables to the clipboard. NOTE Only the selected variables visible in the Variables view are copied. Variables listed outside the boundary of the view are not in memory and can't be copied at this time.
Enable | Enables the selected variable.
Disable | Disables the selected variable.
Cast To Type... | Opens the Cast to Type dialog where you can assign a new type to the variable. Enter the type and click OK. All cast variables are then shown using the Restore Original Type menu option making them easy to identify and restore later.
Display As Array... | Opens the Display as Array dialog where you can set array parameters to show the variables. Enter the Start index and Length, then click OK to update how the variables are shown in the Variables view.
View Memory | Opens a Memory view on the selected variable so you can examine it.
Format | Change the selected variable's display format. The default setting is Natural, or the format assigned when the variable is defined. For example, the decimal value of 256 would appear as: Binary (0b100000) Natural (256) Decimal (256) Hexadecimal (0x100)
Find... | Opens a Find dialog to search for variables. Enter the variable to search for and click OK.
Change Value... | Opens the Set Value dialog where you can modify the value assigned to the selected variable. Change the value and click OK.
Add Global Variables... | Select to open the Global Variables dialog where you can select one or more global variables to display in the Variables view. Global variables appear at the top of the variables list.
Remove Global Variables | Remove the selected global variables from the Variables view.
Remove All Global Variables | Remove all global variables from the Variables view.
Add Watchpoint (C/C++)... | Opens the Add Watchpoint dialog enabling you to define a watchpoint on the variable.
Watch | Creates a watchpoint on the selected variable and displays it in the Watchpoint view.

##### Other references

- Variables and Expressions Overview