---
title: "Live values in the code"
---

# Live values in the code

Show the current value of each visible variable next to its identifier in Structured Text and TwinCAT object editors, resolved exactly against the connected TwinCAT target's symbol table.

**State:** TwinCAT kit shipped: tested over real loopback TCP against a model of a TwinCAT router, never against a real Beckhoff PLC. Live values write nothing and change no state.

## Turn live values on

1. Connect a TwinCAT target (see [Connect to controllers](https://neuralinverse.com/docs/modules/plc/targets/)).
2. Run **Show Live Values**, a toggle in the Command Palette and in the context menu of `.st` and TwinCAT object editors. It is off by default, one switch for every editor, and off again at each start and when the PLC environment stops. If the symbols are not uploaded yet, turning it on uploads them.
3. With several PLC projects (`.plcproj`) in the workspace, the Editor asks which one the connected target runs and keeps the answer for that target in the workspace. **Choose PLC Project for Live Values** changes it. With one PLC project, it is that one: nothing on the wire names the project.

Each variable's current value then shows right after its identifier on the visible lines of `.st` files and of the Structured Text inside TwinCAT object files, in declarations and in code. The [diagrams](https://neuralinverse.com/docs/modules/plc/diagrams/) show values on plain operands with the same rules.

## How values look

- BOOL TRUE is bold in the passed colour; FALSE is dimmed. Long strings are shortened.
- The hover gives the value, type, symbol path, index group, offset and size, the comment, the device's timestamp of the value, the target, and that it is read only.
- **Announce Live Value** reads the same for the identifier at the cursor to a screen reader, or says why there is none.
- When the connection is lost, the last values stay, marked "(stale)" and struck through, until a disconnect or a new connection.
- When the symbol version changes (an online change or a download), values are marked stale and resolved again once the symbols are uploaded again. When change detection is unavailable, the hover says so with the reason.

## Where a value shows, and where it never guesses

A value is shown only where the symbol path follows exactly from the source and the uploaded table:

- program variables (`MAIN.nCounter`);
- global list variables (`GVL.x`; unqualified only when one list declares it);
- members of structs and blocks (`MAIN.TON1.Q`), also as formal parameters of a block call;
- a function block's own variables, only when the table holds exactly one instance of the block, none in an array.

Variables of functions, methods and accessors, `VAR_TEMP`, `VAR_IN_OUT`, anything after an index `[i]` or a dereference, and any path the table does not hold show nothing. In a block that extends a library block, a name the block does not declare itself shows nothing. Only elementary values are shown (BOOL, numbers, enumerations, time types, strings); structs, arrays and block instances show their members where the code uses them. Files of another PLC project, and `.st` files outside the project's folder, show nothing.

## How values are read

Values arrive by ADS notifications on change, checked every 100 ms, one per visible variable and at most 100 for every editor together. Scrolling re-resolves after 150 ms, and the notifications of variables scrolled away are deleted. All are deleted when the values are hidden, the target is disconnected, the environment stops or the window closes.

## Not verified

- Symbol paths and member offsets against a real TwinCAT symbol table; whether TwinCAT lists inherited members of an extended block; bit-addressed variables (`AT %MX`), which are left out.
- The symbol version notification against a real online change and download.
- Live values in the diagram against a connected target.
