Assignment (:=)

The := operator assigns a variable with an expression and returns the result.

Syntax

variable := expr

Usage

The := assignment operator puts a value in the left-hand variable and the resulting value can again be used in an expression.

Do not confuse with the LET instruction.

The := assignment operator has the lowest precedence, it can be used at many places and can simplify coding.

Example

In the next example, the := operator is used to increment the array index before usage:

MAIN
  DEFINE arr DYNAMIC ARRAY OF STRING,
         idx INTEGER
  LET idx = 0
  LET arr[idx:=idx+1] = "One"
  LET arr[idx:=idx+1] = "Two"
  LET arr[idx:=idx+1] = "Three"
END MAIN