ST REPL — Check Structured Text Live
October 2026 | ControlForge
Type Structured Text at a running controller and see the answer. Use it to check what a builtin really does before a program relies on it.
What it is
The REPL evaluates ST in a scratch interpreter on the target. That interpreter has:
- the same builtins and libraries (OSCAT included) as the controller's tasks;
- its own variables.
It can never see or change a running task, a GVL, I/O or retained values. By default it also refuses every builtin that reaches off the box or acts on the instance (see below). It needs the engineer role.
Three ways in:
controlforge repl --url http://<host>:<port>(terminal)POST /api/st/eval(HTTP)controlforge_st_eval(MCP / the AI assistant)
A session
st> ? INSERT('ABC','XY',2)
= "ABXYC" : STRING
st> ? BOOL_TO_INT(TRUE)
= 1 : INT
st> VAR i : INT; END_VAR
st> FOR i := 1 TO 3 DO
..> ;
..> END_FOR;
i = 3 : INT
st> :both ? 7 * 6 + 1
interpreter vm
result 43 : LINT 43 : LINT
gate: eligible (64 scans compared byte-identical)
AGREE
st> :force ACOSH
st> ? ACOSH(2.0)
= 1.316958 : REAL (inferred)
? exprevaluates an expression. A lone builtin call is typed by its published signature (BOOL_TO_INTis an INT) when the value really has that type; anything else is typed from the value and marked(inferred): each integer width by name (INT, DINT, UDINT …), an unsigned value by width (UINT, never WORD, which the value alone cannot tell apart). Arithmetic on integers is DINT or wider.- Any other input runs as statements. Open with
VAR … END_VARto declare; declarations and values persist for the session. - A block (IF, FOR, VAR, FUNCTION, …) keeps the prompt open until it is closed.
Commands
| command | does |
|---|---|
:scan N | run N scans per input |
:vars | list the session's variables |
:reset | start a fresh session |
:engine interpreter|vm|both | choose the engine |
:both <src> | run on the interpreter and the compute-tier VM, flag every difference |
:force NAME… / :force none | run these names as their ST library implementation (FORCELIB_FUNCTION) |
:load file.st | evaluate a file |
:timeout MS | wall-clock budget per input |
:clock MS | virtual milliseconds per scan, for timer checks |
:effects on|off | let inputs act on the instance (warning; audited) |
:help, :quit |
Good to know
- The VM is never a silent fallback. If the compute tier's equivalence gate refuses the source, the REPL prints the gate's reason. It does not quietly run the interpreter instead.
- The REPL cannot act on the plant by default. Builtins that touch the instance (ALARM_, HIST_, NOTIFY, EVENT_, SPINE_, SIM_, TASK_, RECIPE_*, …) and every capability-gated builtin are refused with a clear message.
:effects on(orallow_side_effects: true) runs them as a task would. It prints a warning, the prompt becomesst!>, and every eval is audited with its source. - Runaway code is bounded. An infinite loop is cut off at the timeout on the interpreter, on the VM and in the equivalence gate. A builtin that blocks is abandoned after the timeout. At most 4 evals run at once, and declared arrays are capped at 16 MiB.
- Names the REPL cannot see are errors. A running program's variable (
POU_A.n), a project GVL or a typo of one is refused as "not visible here". It does not quietly read as 0. - Faults are exact. You see the same fault text a task would raise.
Full contract: docs/features/st-repl.md.