# Set external access and write limits

> Make a variable read-only, hidden or writable from outside the eaxPLC program, and bound the values outside clients may write, from the tag database; then apply the change with Test edits or Build & Deploy and check that writes are refused.

Product: eaxPLC · Type: How-to guide · Editions: Free, Pro
Source: https://eaxware.com/docs/eaxplc/how-to/set-external-access-and-write-limits/
Verified against commit 9828d73.

## Goal

You decide, per variable, what clients outside the program may do with it (HMI writes over the runtime API, OPC UA, UNS, Modbus TCP, direct-address writes, forces) and which values they may write. The PLC enforces it; see [Data model](/docs/eaxplc/explanation/data-model/#external-access) for the rules.

## Before you start

- You are an engineer (Lead_Engineer or Administrator).
- The declaring POU (the global variable list or program) is not checked out by someone else, and has no unsaved edits open in your editor. If it has, save it first: the tag database refuses so that the two edits do not overwrite each other.
- Access and write range are part of the signed program. A change runs only after a **Test edits** or a **Build & Deploy**, with its e-signature as your deploy settings require.

## 1. Open the tag database

Click **Tags** in the toolbar. There is one row per global, program variable and alias, with its scope, data type, live value, **External access**, **Write range** and **Initial value**.
[Image: The eaxPLC tag database: global and program variables with their scope, data type, live value, external access, write range, initial value, address, alias target and constant flag, and Go to, Refs, Watch, Force and Delete actions per row.]
[Image: The eaxPLC tag database: global and program variables with their scope, data type, live value, external access, write range, initial value, address, alias target and constant flag, and Go to, Refs, Watch, Force and Delete actions per row.]

The tag database: signed columns (access, write range, initial value) go to the POU's draft; documentation columns save at once.
## 2. Set the access

1. Double-click the variable's **External access** cell and choose **None**, **Read** or **Read-write**.
2. The first edit of a POU offers to check it out. Accept.
3. The cell shows the new value with a **draft** mark. The change is in the POU's draft, not in the running program, and not yet in the saved project. The pending chip above the grid counts the draft changes and filters to them.

A CONSTANT is always read-only from outside, whatever you choose. An alias can only narrow its target's access, and its own narrower access applies to the alias's name only.

## 3. Set a write range

1. Double-click the **Write range** cell and type `low..high`, for example `0.0..120.0` (numbers, low not above high). Leave it empty to remove the range.
2. It applies to numeric variables. A subrange type (`INT(0..3000)`) already limits writes to its bounds; a write range can narrow them further. To bound one member of a structure or function block in every instance, put the `write_range` attribute on the member in its data type or block.

The edit writes this into the declaration text, keeping every other byte of the POU, comments included:

```text
{attribute 'access' := 'read_write'}
{attribute 'write_range' := '0.0..120.0'}
LineSpeed : REAL := 12.5;
```

You can also type the attributes in the code editor yourself; the result is the same.

## 4. Save and apply

1. In the row, click **Go to**: the POU opens with your draft restored. Check the text and save it (**Ctrl+S**).
2. Click **Test edits**. The impact report's **Access** tab lists every variable whose effective access widens or narrows. A widening on a safety target is shown in rose; for an AI-made program it blocks the test (`ai_widens_access`).
3. Sign and test. The new access applies from the test's first cycle. **Untest** puts the accepted program's access back at once; **Accept** makes it permanent.

Without an online edit, **Build & Deploy** applies it at the deploy.

## 5. Check it

From an HMI or any client with the write right:

| Write | Answer |
|---|---|
| By name to a variable with access read or none | `403`, `WRITE_ACCESS_DENIED: LineSpeed is read-only from outside (access read) in the running program ...` |
| Outside the write range | `400`, `WRITE_OUT_OF_RANGE: 150 is outside the write range of LineSpeed (0..120) ...` |
| By member path (`Recipes[2].Temp_SP`) | the same checks on the member: access narrowed through each member, its own write range or the enclosing one |
| By path to a function block output or internal variable (`Line2.Valves[3].Out`) | `400`: only a function block's `VAR_INPUT`s are written or forced from outside |
| By direct address over the protected storage (`%MD...`) | the same refusals, naming the variable |
| A force on access none | `403`, `FORCE_ACCESS_DENIED` (access read can be forced) |
| OPC UA | access none: the node is gone from the address space; read: `BadNotWritable`; out of range: `BadOutOfRange`; without the `plc.write` right: `BadUserAccessDenied` |
| UNS | access none: no longer published; read: the command answers an error |

Each refusal is in the PLC's audit trail (`WRITE_DENIED`, `WRITE_REFUSED` or `FORCE_DENIED`).

## Troubleshooting

| Message or code | Cause and fix |
|---|---|
| `423`, *you do not hold the lock of GVL_Line* | Someone else has the POU checked out. Ask them to release it. |
| `409`, *GVL_Line changed since you opened it* | The POU was saved meanwhile. Reload the view and edit again. |
| *attribute 'access' := 'rw': the access is none, read or read_write* | A hand-written attribute has a bad value. Use `none`, `read` or `read_write`. |
| *attribute 'write_range' := '120..0': expected 'low..high' (numbers, low <= high)* | Swap the bounds, or fix the numbers. |
| `forced_symbol_changes` on **Test edits** | The test makes a forced variable access none. Release the force first, then test. |
| An eaxScada tag stopped updating | Its variable is now access none, so it is no longer published. Use `read` to publish it read-only. |

## Related

- [Data model: global variables, data types and external access](/docs/eaxplc/explanation/data-model/)
- [Make online edits](/docs/eaxplc/how-to/make-online-edits/)
- [Constants, outside writes and forces](/docs/eaxplc/reference/constants-writes-and-forces/)
