Basics
Execution
Extended code is executed top-to-bottom, and the result of executing the last line is returned.
2 + 2
3 + 3
4 + 4
The above Extended code would return a value of 8, as that is the result from the last line. The rest of the code is still executed, it is just not included in the return value. If the last line is part of a statement, such as a forEach, then the result of that statement will be returned. This behavior is important to keep in mind to make sure the desired value is returned.
Variables
Variables can be used to store a value, such as the result of an expression. When a variable is declared, it is given a name to identify it by. This name can then be used to access the value in the variable.
Syntax |
Definition |
|
Assigns the value to the variable name |
Variables must be assigned a value when they are declared.
The assignment operator :=
assigns the value of the righthand side to the variable on the left.
Note that this is not the same thing as the equality =
operator.
Examples
myNum := 5 // Assigns a value of 5 to the variable myNum
myStr := "Hello World" // Assigns a value of "Hello World" to the variable myStr
total := 1 + 2 // Evaluates the expression and assigns the result (3) to the variable total
After they are assigned, variables can be used in subsequent expressions by referencing their name:
apples := 10
oranges := 15
totalFruits := apples + oranges
totalFruits // 25
Variable Scope
The scope of a variable encompasses the entire expression.
This means that variables created in statements like IF-THEN-ELSE
blocks, will be available outside of the block as well.
Examples
var := 10
IF var > 5 THEN
var2 := "I'M STILL ACCESSIBLE"
ENDIF
var2 // "I'M STILL ACCESSIBLE"
Comments
Comments can be used to write messages within code that will be ignored when it is run. They are very useful for documenting code so that others can understand what it does and how it is supposed to run. They are also commonly used to document smaller pieces of code, particularly ones that serve a specific function, or are more complex than others. They can be written using a double forward forward slash
//
:It is also possible to write multiline comments using an opening
/*
paired with a closing*/
.