User Tools

Site Tools

Scripts Editor

Script editor allows you to write and manage scripts.

  1. Script list
  2. Selected script properties area
  3. Code editor area
  4. Edit tool buttons (full screen, insert function calls, show/hide console window, save)
  5. Create new script button

The main editor's window:

Script list (1)

The scripts run in the order how they are sorted in the list. This order can be easily changed by dragging a script into a new location.

The line starts with the script Id. This number is shown in communication log to track the relevant script. E.g.

Jul 26 17:23:27.450: ERROR: LUA scripts: Can't execute LUA script #3.

Then goes title and two or three icons indicating type of script (see more details below), wether it has modifications, and its running state (Enabled/Disabled). In this example all possible types are shown with their respective icons.

Property area (2)

You can set here name for the script, select type, disable or enable it and give short description.

There are 5 types of scripts:

  • Execute in every loop - script runs in every scan after reading registers in connections
  • Script for dashboard - script runs upon clicking the button with this script “attached” to it
  • Execute on register's value change - if there is difference of the register's value read in previous and current scan then script will be executed
  • Script for calendar - the script is set as start or end task action in the calendar
  • Execute once on project start - runs one time on the very first scan during project start

Editor (3)

WebHMI has handy code editor with useful features:

  • syntax highlighting
  • code completion
  • syntax validation
  • debugging console
  • supports a number of typical hotkeys

Table of hotkeys:

F6toggle compact / full-screen mode
Crtl-Ssave the script
Ctrl-Ffind and highlight occurence
Ctrl-Hfind and replace
Ctrl-Aselect all
Ctrl-LSelect specific line
Ctrl-Ddelete line
Ctrl-[ or Shift-Tabdecrease indent
Ctrl-] or Tab increase indent
Ctrl-Uconvert text to upper case

Editor toolbar (4)

The toolbar has the following buttons (from left to right):

  • Toggle full / compact screen mode button (hotkey: F6)
  • Insert GetReg call (will be explained further in GetReg function details)
  • Insert SetReg call
  • Insert WriteReg call
  • Show/hide console button
  • Save script (hotkey Ctrl-S)
  • Clone script button
  • Delete script button

In the following picture, the full editor mode with console activated is shown:

Adding script (5)

When there are no scripts yet in the project, the +Add script button is placed in the page center. After adding a script it is moved to the top-right page corner.

Page Tools