# Find references and the I/O map in eaxPLC

> List every place a PLC variable is read and written, see each %I, %Q and %M address with its variables and fieldbus point, and run the output-conflict checks.

Product: eaxPLC · Type: How-to guide · Editions: Free, Pro
Source: https://eaxware.com/docs/eaxplc/how-to/find-references-and-io-map/
Status: migrated page, not yet verified against the current code.

## Goal

Before you change a variable, an output or a fieldbus mapping, you know
every place in the program that reads or writes it, which fieldbus point
each address is exchanged with, and (in eaxPLC Standard and Performance)
whether an output is written from more than one place or more than one task.

Find references and the I/O map are in every edition, eaxPLC Free included.
The checks are in eaxPLC Standard and Performance.

## Before you start

- A program is deployed. The PLC's compiler builds the cross-reference
  with every deploy and online change, from the program's syntax tree (not
  a text search). Positions are those of the deployed program.
- Any signed-in Studio user can read the cross-reference and the I/O map.

## Find the references of a variable

1. In the Structured Text editor, put the cursor on a variable name.
2. Press **Shift+F12**, or right-click and choose **Find References**.
3. The references panel opens under the editor. It lists:
   - the **declaration**;
   - the **writes**, marked `WRITE` (a filled badge with a bar);
   - the **reads**, marked `READ` (an outlined badge);
   - the **calls** of a function block instance, marked `CALL`.

   Each row shows the line and column, the POU, the context and the line of
   code, with the name highlighted.
4. Click a row (or press Enter on it) to jump to that line in the editor.

Put the cursor on the member of an instance (`TON_1.Q`) to list that member,
or on the instance (`TON_1`) to list the instance and all its members. A
variable located with `AT` and its address are the same storage: the
references of `Motor AT %QX0.0` include the code that uses `%QX0.0` directly.

If the editor holds changes that are not deployed, the panel says so: the
line numbers are those of the deployed version.

### What the contexts mean

| Context | Access | Example |
|---|---|---|
| assignment | write | `Motor := TRUE;` |
| expression | read | `Speed := Setpoint * 2;` reads `Setpoint` |
| IF condition | read | `IF StartPB THEN` (and `ELSIF`) |
| CASE selector, CASE label | read | `CASE Mode OF`, a constant used as a label |
| WHILE condition, UNTIL condition | read | `WHILE Sum < 100 DO`, `UNTIL Done` |
| FOR variable | read and write | `FOR i := ...` (written and incremented) |
| FOR bound | read | the start, `TO` limit and `BY` step |
| function argument | read | `LIMIT(0, Level, 100)` |
| array index | read | `Arr[i]` reads `i`; writing `Arr[i]` is a write of `Arr` |
| block call | call | `TON_1(...)` |
| block input | write | `TON_1(IN := x)` writes `TON_1.IN` |
| block input value | read | `TON_1(IN := x)` reads `x` |
| block output (=>) | read / write | `TON_1(Q => Done)` reads `TON_1.Q` and writes `Done` |
| written by the block | write | when `TON_1` runs it writes its outputs `TON_1.Q` and `TON_1.ET` |
| block in-out (by reference) | read and write | a `VAR_IN_OUT` parameter: what is passed may be read and written |
| initial value | write | `Limit : INT := 10;` |

A function block's own outputs are written by the block when it is called:
the cross-reference records them as writes of the instance at the call
(`written by the block`). For a function block written in Structured Text,
only the outputs its body writes are recorded.

When the compiler cannot tell whether a reference reads or writes (a
`VAR_IN_OUT` parameter), it records both. A reference is never left out.

## Open the Cross-ref view

Click **Cross-ref** in the view bar (or **View > Cross-reference, I/O Map
& Checks**). It has three tabs.

### Variables

Every symbol of the program: variables, function block instances and their
members, function block locals and direct addresses, with their type,
address, number of writes and reads, POU and Unified Namespace path.

- Filter by name or address, and by kind.
- Double-click a row, or select it and press Enter or Shift+F12, to list its
  references in the editor.

### I/O map

One row per `%I`, `%Q` and `%M` address of the program, plus every fieldbus
point the program does not use.

| Column | Shows |
|---|---|
| Address, Type, Bits | the address and the size of what is stored there |
| Variables | the variables located there (`AT`), and the address itself when the code uses it directly |
| Writes / reads | how many places write and read it |
| Bus, Device, Entry | the fieldbus, the device and the I/O entry (`[n]` for the nth element of an entry) |
| Bus point | Modbus TCP: the area and the 0-based coil or register number. EtherNet/IP: the assembly instance and the byte (and bit) offset. EtherCAT: the slave's position and the byte (and bit) offset in its process data |
| Status | **On a bus**, **No bus point** (an input or output no bus point feeds or reads), **Unused point** (a bus point no address of the program uses), **Memory** (`%M`) |

Filter by text (address, variable, bus, device), by area and by status.
A bus that is switched off shows `(off)` after its name.

In a narrow window the I/O map starts with its secondary columns hidden,
so the others fit: below 1440 pixels **Bits**, **Writes / reads**,
**Entry** and **Dir**, below 1280 pixels also **Type** and **Device**.
**Columns**, in the grid's toolbar before **CSV**, shows them again (your
choice wins over the window width and is remembered for this table;
**Reset** goes back to the defaults). **Address** is pinned and always
shown. **CSV** exports the columns shown.

### Checks (eaxPLC Standard and Performance)

| Check | Severity | Finds |
|---|---|---|
| multiple-writers | warning | an output (`%Q`, or a variable located in `%Q`) written in more than one place. Writes through overlapping addresses (`%QB1` and `%QX1.3`) count as the same output. The last write in the scan wins |
| multiple-tasks | error | an output written from more than one task: the program that writes it is called by two enabled tasks |
| unused-input | warning / info | an input (`%I`) the program never reads; information for a fieldbus input point that no address of the program covers |
| written-not-read | info | a variable written but never read. Outputs and function block outputs are not reported: the field or the caller reads them |
| read-not-written | info | a variable read but never written. Inputs, retained variables, function block inputs and variables that UNS commands or OPC UA clients may write (`--uns-writable`) are not reported. A variable only set by its initial value is reported with a hint to declare it `CONSTANT` |
| overlapping-addresses | warning / info | located variables that share memory (`A AT %MW0` and `B AT %MB1`); information when the code uses an address that partly overlaps a located variable |

Every result has a severity, a message and its locations. Click a location
to jump to it in the editor.

In eaxPLC Free the tab says the checks are available in eaxPLC Standard and
Performance, with a link to **Help > Licence**. Find references and the I/O
map keep working.

## Use the API

The same data, for scripts and for eaxScada. Any signed-in user can read it
(`GET` only):

| Request | Returns |
|---|---|
| `GET /api/xref?offset=&limit=&q=&kind=` | the symbols, 500 per page by default (5000 at most); `next_offset` when there are more; `q` filters by name or address, `kind` by kind (`variable`, `fb-instance`, `fb-member`, `fb-local`, `address`) |
| `GET /api/xref/symbol?name=Motor` | one symbol with its members and aliases (404 if the deployed program has no such symbol) |
| `GET /api/io-map` | the I/O map rows and a summary |
| `GET /api/xref/checks` | the check results and their counts; 403 with `available_in: ["Standard", "Performance"]` in eaxPLC Free |

Each symbol carries its declaration (`pou`, `file`, `line`, `col`), its
references (`access`: `read`, `write`, `readwrite` or `call`; `context`;
`via`, the instance whose call made the reference) and, when the PLC
publishes to the Unified Namespace (`--uns-prefix`), `uns.path` and
`uns.subject`: the tag path it publishes as, and whether UNS commands may
write it.

## Verify

1. Deploy a program with an output written twice, for example
   `Lamp := TRUE;` and `%QX0.1 := FALSE;` with `Lamp AT %QX0.1 : BOOL;`.
2. Put the cursor on `Lamp` and press Shift+F12: the panel lists both writes.
3. In eaxPLC Standard or Performance, the **Checks** tab reports
   `multiple-writers` for `Lamp, %QX0.1` with both lines.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| "is not a variable of the deployed program" | the name is a keyword, a literal, or a variable that is not deployed yet | deploy the program (F11), then search again |
| The jump lands on the wrong line | the editor holds changes that are not deployed (the panel says so) | deploy, or read the line numbers as those of the deployed version |
| "outside the editor" in the log | the reference is in a FUNCTION_BLOCK or before the program's declarations, which the editor does not show | use the line and column shown in the row |
| The I/O map shows no bus | no fieldbus is configured on this PLC | configure it in the **Fieldbus** view |
| The Checks tab asks for a licence | the PLC runs eaxPLC Free | install a Standard or Performance licence (**Help > Licence**) |
