544
OPUS Projektor Manual
JavaScript
{
print("Failed to send CAN messge!");
}
includeFile - include another JavaScript file
With this command it is possible to execute a JavaScript file from within another JavaScript
file.
Example:
includeFile("example.js")
The included file will be executed as if the source code was written in the source file (except
when it's a function). This is useful if you have a part of code that you need to execute in many
different places.
function - use functions in JavaScript
It is possible to use functions in JavaScript. To create a function, use the following syntax:
Example:
function function_name (input variables)
{
<code>
return return_value;
}
The input variables as well as the return value are optional. The input variables will be
forwardef from the calling JavaScript. Executing the function looks like this:
Example:
var result = function (input variables);
You can combine this with the includeFile function to create a set of multi purpose JavaScript
functions that you can use in different places in your project (Note that you need to declare the
functions globally for them to stay alive).
Please note that for a function to be declared once and stay "alive, it needs to be declared
like this:
function_name = function function_name (input variables)
{
<code>
return return_value;
}
generateAction - simulate encoder actions
It is possible to call functions in JavaScript that simulate encoder actions:
Example:
generateAction("Navigate Up");//simulates a counterclockwise
encoder movement
generateAction("Navigate Down");//simulates a clockwise encoder
movement
generateAction("Navigate Confirm");//simulates an encoder press
deletePageHistory();