7 Scripting
25
The snippet name selector can be used to choose an existing snippet, or to enter a new name, e.g. to create a
new snippet or save the current snippet under a different name. Use the "Load" button to load the snippet with the
selected name in the snippet editor. Use the "Save" button to save the currently edited snippet under the selected
name. The "Remove" button can be used to erase the selected snippet.
Snippet code can be copied/pasted from/to the main script code. It is not subject to syntax or other checks so it's
OK to place incomplete code fragments there.
Snippet names starting with 'default.' are reserved for snippets shipped with the device. It is not recommended to
change or create snippets with such names because your changes may be erased on an upgrade.
7.5
Threading
Multiple threads of execution can be running at the same time. Any number of threads may run concurrently.
Thread control
No threads currently running.
Start
thread:
Start
do_some_lua_stuff
User script thread list
Threads can be started from the web UI, via an HTTP request, by an
trigger, or from other threads using
thread.run
. They can be explicitly stopped using the web UI or by calling
thread.kill
or
thread.
←
-
killall
from the script, or implicitly by calling
thread.limit
.
Every thread has an 'origin', which is usually a string identifying the function that started the thread. For instance,
when you create a function like this:
function my_function()
... statements go here ...
end
and then start it with the web UI, its origin is the
"my_function"
string. Threads created by other threads inherit
their parent's origin, which can be useful when stopping a group of threads.
7.6
API levels
The scripting engine presents two sets of functions that you can use to write scripts:
• Legacy functions — functions which are designed to resemble the BASIC commands of the previous gener-
ations of EPCR/LPC controllers;
• Modern API — functions and objects which are designed to be easier to use.
You can use and even freely mix them as you wish, but only the modern API will receive further development atten-
tion. Some features are exposed only via the modern API because they had no corresponding legacy commands.
DLI LPC9 User’s Guide: 1.7.24.0
Summary of Contents for LPC9
Page 1: ...DLI LPC9 User s Guide 1 7 24 0 ...
Page 81: ......