Syntax
Syntax Examples
Modules and Imports
- To import a module, use the
importkeyword followed by the modulefilename,standard library name, or aURL.
import "./module";
import "std:math";
import "http://example.com/module.ext";Variables
- To declare a variable, use the
letkeyword followed by the variable name.
let name = "Extron";
let x = 12;
let y = [1, 2, 3];- To re-assign a value to a variable, use the
setkeyword followed by the variable name.
set name = "Hello Visitor";
set x = 1;Functions
- All functions must be assigned to a variable. To declare a function use the
fnkeyword.
let add = fn(a, b) {
a + b;
};
print(add (1, 2));
Console
3Conditional Statements
- To create a conditional statement, use the
ifkeyword followed by the condition.
let x = 10;
if (x > 5) {
print("x is greater than 5");
} else {
print("x is less than or equal to 5");
}
Console
x is greater than 5Loops
- To create a loop, use the
loopkeyword followed by the loop condition. Use thebreakkeyword to exit the loop.
let i = 0;
loop {
if (i > 2) {
break;
}
let a = ["a","b","c"];
print(a[i]);
set i = i + 1;
}
Console
a
b
c Type Checking
- To check the type of a variable, use the
typeofkeyword followed by the variable name.
let x = 10;
print(typeof x);
Console
number Comments
- To create a single-line comment, use the
//symbol.
// This is a single-line comment