31
6. Euresys GenApi scripts
The Euresys GenApi Script language is documented in a few GenApi scripts. For convenience,
they are also included here.
6.1. doc/basics.js
// Euresys GenApi Script uses a syntax inspired by JavaScript, but is not
// exactly JavaScript. Using the extension .js for scripts is just a way to get
// proper syntax highlighting in text editors.
//
// This file describes the basics of Euresys GenApi Script. It can be executed
// by running 'gentl script <path-to-coaxlink-scripts-dir>/doc/basics.js', or
// more simply 'gentl script coaxlink://doc/basics.js'.
// Euresys GenApi Script is case-sensitive.
// Statements are always separated by semicolons (JavaScript is more
// permissive).
// Single-line comment
/* Multi-line comment
(cannot be nested)
*/
// Function declaration
function multiply(a, b) {
return a * b;
}
// Functions can be nested
function sumOfSquares(a, b) {
function square(x) {
return x * x;
}
return square(a) + square(b);
}
// Variable declaration
function Variables() {
var x = 1;
// 1
var y = 2 * x;
// 2
var z;
// undefined
}
// Data types
function DataTypes() {
// Primitive types: Boolean, Number, String, undefined
function Booleans() {
var x = true;
6. Euresys GenApi scripts
Coaxlink
Programmer Guide