<< Click to Display Table of Contents >> Navigation: Modbus Universal MasterOPC Server > Lua 5.1 Reference Manual > Introduction > The Script Editor |
Interface of the Script Editor
The title bar of the Script Editor
The toolbar of the Script Editor
The object tree of the Script Editor
The function tree of the Script Editor
Operations in the Script Editor
Interface of the Script Editor
The screenshot below shows an interface of the Script Editor.
In the editor window, the following areas may be marked out:
The title bar
The toolbar
The script code editor
The object tree
The function tree
The Messages area
The title bar of the Script Editor
The title bar of the Script Editor is provided with the standard window tools:
– open/close the context menu:
– restore the window
– close the window (exit the Script Editor)
The toolbar of the Script Editor
The toolbar of the Script Editor is shown in the screenshot below:
The toolbar contains the following tools:
– copy a text highlighted in the script code editor to the clipboard
– cut a text highlighted in the script code editor to the clipboard
– insert a text from the clipboard to the specified position of the script code editor
– undo the last action
– redo the last action
– open the menu to search for a substring through a program text:
The menu tools are:
– close the menu
– this combo-box contains a list of substrings typed for search during a session
– search forward
– search back
– move cursor to the text beginning
Match case – take a letter case into account while searching
Whole words – search for a whole word
From cursor – search from cursor
– open the replace dialog:
– expand all functions:
– fold all functions:
– compile the current code
When creating a script, the following functions are created automatically: the function executed at node start, the function executed at node stop, and the respective processing function (for instance, the function OnRead() is created in a script of reading):
Code lines are numerated in the editor.
The object tree of the Script Editor
In this window, an object tree of the current configuration is displayed (that is, the same as in the window Objects of the server – see Hierarchy of Tree Objects ):
A double click over a tag inserts the full name of that tag into the current code (into the current cursor position).
The function tree of the Script Editor
This window displays a tree of functions and constants grouped by belonging to libraries.
The main destination of the tree is fast input of functions to a script. Note that the tree contains only the most important Lua functions. Other functions can be type manually.
A double click over a function/constant inserts it into the current code (into the current cursor position).
To open context help for a highlighted function, click F1.
Functions and constants are described in the following sections:
string – String Manipulation
math – Mathematical Functions
os – Operating System Facilities
io – Input and Output Facilities
table – Table Manipulation
server – Function Invocation , Functions to Operate with Tags , Functions to Operate with Nodes , Functions to Operate with Devices , Functions to Operate with Sub-Devices , Functions to Operate with Ports , Functions to Operate with the Log (in the section The SERVER Library)
bit – Bitwise Data Operations (in the section The BIT Library)
time – Time Operations (in the section The TIME Library)
modbus – MODBUS Functions (in the section The MODBUS Library)
sqlite3 – SQLite3 Functions , Database Methods , Methods for Prepared Statements , Methods for Callback Contexts (in the section LuaSQLite3 Reference Manual)
In this area, errors of script compilation are indicated – see Operations in the Script Editor .
Operations in the Script Editor
A code can be set manually or using the trees of objects and functions. To insert a function/tag into the current cursor position in the code, double-click that function/tag in the respective window (see Interface of the Script Editor ).
When typing a code manually: as soon as a dot after a library name is typed, the prompter is displayed, which contains functions of that library:
In the editor, standard operations of text editors are supported. To perform them, use a mouse, keys or key combinations (e.g. Alt-X cuts the highlighted text into the clipboard).
If a code is changed, it must be compiled ( ). The following message is displayed when attempting to exit the Script Editor without previous undoing changes (
) or compiling (
) (if a code is compiled successfully, it is saved):
If compilation errors are detected (see the screenshot below):
The editor marks (
) a line that follows by the first program line containing an error.
The Message area displays an error description.
If compilation is successful, the respective message is displayed:
The current (i.e. edited) code is save to the file ..\SCRIPTFILES\TEMPLUA.