Compound Assignment & Aliases

DWScript provides several operators familiar to developers coming from C-family languages.

Compound Assignment

Compound assignment operators combine an arithmetic operation with an assignment. They are shorthand for variable := variable <op> expression.

Operator Equivalent Description
+= a := a + b Add and assign
-= a := a - b Subtract and assign
*= a := a * b Multiply and assign
/= a := a / b Divide and assign
var a := 10;
a += 5; 
PrintLn(a);
Result
15

Comparison Aliases

For convenience, DWScript supports C-style symbols for equality and inequality.

Operator Pascal Equivalent Description
== = Equality
!= <> Inequality
var x := 10;
if (x == 10) then
  PrintLn('Matches');

if (x != 0) then
  PrintLn('Non-zero');
Result
Matches
Non-zero
On this page