The Script Editor

<< Click to Display Table of Contents >>

Navigation:  Modbus Universal MasterOPC Server > Lua 5.1 Reference Manual > Introduction >

The Script Editor

The Script Editor

mbul_mail Interface of the Script Editor

mbul_mail The title bar of the Script Editor

mbul_mail The toolbar of the Script Editor

mbul_mail The script code editor

mbul_mail The object tree of the Script Editor

mbul_mail The function tree of the Script Editor

mbul_mail The 'Messages' area

mbul_mail Operations in the Script Editor

Interface of the Script Editor

The screenshot below shows an interface of the Script Editor.

lua_img2

In the editor window, the following areas may be marked out:

mbul   The title bar

mbul   The toolbar

mbul   The script code editor

mbul   The object tree

mbul   The function tree

mbul   The Messages area

The title bar of the Script Editor

The title bar of the Script Editor is provided with the standard window tools:

lua_img3 – open/close the context menu:

lua_img4

lua_img5 – restore the window

lua_img6 – 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:

lua_img7

The toolbar contains the following tools:

mbul   lua_img8 – copy a text highlighted in the script code editor to the clipboard

mbul   lua_img9 – cut a text highlighted in the script code editor to the clipboard

mbul   lua_img10 – insert a text from the clipboard to the specified position of the script code editor

mbul   lua_img11 – undo the last action

mbul   lua_img12 – redo the last action

mbul   lua_img13 – open the menu to search for a substring through a program text:

lua_img14

The menu tools are:

mbul   lua_img15 – close the menu

mbul   lua_img16 – this combo-box contains a list of substrings typed for search during a session

mbul   lua_img17 – search forward

mbul   lua_img18 – search back

mbul   lua_img19 – move cursor to the text beginning

mbul   Match case – take a letter case into account while searching

mbul   Whole words – search for a whole word

mbul   From cursor – search from cursor

mbul   lua_img20 – open the replace dialog:

lua_img21

mbul   lua_img22 – expand all functions:

lua_img23

mbul   lua_img24 – fold all functions:

lua_img25

mbul   lua_img26 – compile the current code

The script code editor

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):

lua_img27

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 ):

lua_img28

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.

lua_img29 lua_img30

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:

mbul   string String Manipulation

mbul   math Mathematical Functions

mbul   os Operating System Facilities

mbul   io Input and Output Facilities

mbul   table Table Manipulation

mbul   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)

mbul   bit Bitwise Data Operations (in the section The BIT Library)

mbul   time Time Operations (in the section The TIME Library)

mbul   modbus MODBUS Functions (in the section The MODBUS Library)

mbul   sqlite3 SQLite3 Functions , Database Methods , Methods for Prepared Statements , Methods for Callback Contexts (in the section LuaSQLite3 Reference Manual)

mbul   Constants

The ’Messages’ area

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:

lua_img31

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 ( lua_img32 ). The following message is displayed when attempting to exit the Script Editor without previous undoing changes ( lua_img33 ) or compiling ( lua_img34 ) (if a code is compiled successfully, it is saved):

lua_img35

If compilation errors are detected (see the screenshot below):

mbul   The editor marks ( lua_img36 ) a line that follows by the first program line containing an error.

mbul   The Message area displays an error description.

lua_img37

If compilation is successful, the respective message is displayed:

lua_img38

The current (i.e. edited) code is save to the file ..\SCRIPTFILES\TEMPLUA.