Skip to content

Log ​

Purpose: write a line to the Log panel and the log file, with variable values filled in.

Log settings

Enter the text in Message, using ${name} to insert a variable. Uses below lists which step sets each variable the message uses.

JSON ​

json
{ "log": "Read 0x0000 = ${v}, n = ${n}" }
{ "log": { "message": "Read 0x0000 = ${v}, n = ${n}" } }
FieldMeaning
messageThe message, 1–127 characters. ${name} is replaced with the variable's value

Result ​

Log is always PASS, and the Actual column shows the message with variables filled in. A variable that does not exist shows as ${name?}, without failing.

Example ​

Reads 0x0000 into v, sets n = 3, then prints Read 0x0000 = 4660, n = 3 and the elapsed time. (0x0000 holds the 0x1234 = 4660 written by the Write example. Run that example first, or the read gives 0.)

Log example result

Notes ​

  • When a script has Log steps, a run creates a log file in the script_logs folder, with the time, case, step and round on every line. Click Open log folder at the top right of the Log panel to open it.
  • Text variables entered with Ask can be inserted with ${name} too; see Ask.

Download the sample script ​

Sample script

Before running it, start a Slave window on 127.0.0.1:502 and click Listen, then open the script with Open JSON in Script mode and click Run. See How to use the examples.

Roach Modbus Tool by Mr.Roach