JASS Tools
JASS Manual


An expression is a segment of code that evaluates to a value (which has a type). Most statements require the use of expressions and variable declarations can be initialized to the value of an expression. Expressions can be arbitrarily nested within other expressions. This section describes the available expressions in JASS.

Arithmetic Operators

expression + expression
expression - expression
expression * expression
expression / expression
- expression
+ expression

These expressions perform addition, subtraction, multiplication, and division on their two operands, and negation and identity on a single operand respectively. Multiplication and division have higher precedence than addition and subtraction; each pair has equal precedence, and they are evaluated left to right. Thus:

a + b * c - d / e

Is equivalent to:

( a + (b * c) ) - (d / e)

Operands must either be integers or reals. If any operand is real, then the result is real, otherwise the result is an integer.

Comparison Operators

expression == expression
expression != expression
expression >= expression
expression <= expression
expression > expression
expression < expression

These expressions evaluate equality, inequality, greater than or equal to, less than or equal to, strictly greater than, and strictly less than, respectively.

The operands to == and != may be of any type, as long as both operands conform to the same native type (e.g., if they are both integers, both strings, one is unit and the other is a destructable, etc.). As a special case, a real may be compared to an integer. For integer, real, boolean, and string values, they test value equality/inequality. For handle types, they test pointer equality (e.g., that both handles refer to the same thing). (Someone want to verify this?)

The other four inequality operators can only take integers and reals as arguments. They return a boolean value indicating whether the inequality was satisfied.

Boolean Operators

expression and expression
expression or expression
not expression
These expressions return the boolean and, or, and not of their operator(s). The expressions must evaluate to booleans. These have the least precedence, so:
a == b and c > d + e or f
Is equivalent to:
( (a == b) and (c > d + e) ) or f

String Operators

expression + expression

+ can be used to concatenate two string variables together (like in Java). The result is of type string.

Function Call


This is similar to the call statement. arguments is a comma separated list of expressions to pass to the function as parameters. The function must return a value (not nothing), which is what this expression evaluates to.

Array Reference


This expression evalues to an element in an array variable. index is an expression that must evaluate to an integer, which serves as the index into the array. The expression evaluates to a value of the basic type of the array.

Function Reference

function func_name

This expression is used to refer to a function. It returns a "pointer" to that function of type code that can be passed to functions that take parameters of code type (e.g., StartThread).

Variable Name


This trivial expression evaluates to the value of a variable. Variable names are composed of alphanumeric characters and underscores but must start with a letter and can not end with an underscore.


Constant values can be expressed for integers, reals, booleans, and stings. In addition, the constant value null, a pointer to nothing, can be expressed as a handle or string type.

Integer constants are expressed as 32-bit twos-complement integral numbers. For example, 0, 1, 2, 4, 10, 14, 1000, 1234, 3245. If the number is prefixed with a 0 (e.g., 016) then the value is interpreted as octal. If the number is prefixed with 0x (e.g., 0xA15F) then the value is interpreted as hexadecimal and can contain the characters a-f or A-F as digits. Integers can also be expressed as four character strings enclosed in single quotes, in which case the value is equal to the bit-string formed by the ASCII bytes (4 bytes = 32 bit value). These values are usually used to reference unit/upgrade/etc. identifiers which are enumerated in the *.slk files. For example, 'abcd', 'AhGn', 'EEEE'.

Real constants are expressed as 32-bit floating point numbers. For example, 1.0, 0.0, .34, 1.5, 1000.3, 324.32, 0.35.

Boolean constants are true and false.

String constants are declared enclosed in double-quotes like "This is a string". The value of a string variable may be null in which case the variable refers to nothing and it is illegal to use it (except to assign a value to it). Within a string constant, the back-slash is used as an escape like in C or Java. For example, to include a double-quote in a string, do "This is a \"string\"".



By enclosing an expression in parenthesis, it is given higher precedence than the immediately surrounding expression. For example:

(1 * (2 + 3) != a) == (b or GetSomeBoolean())
Causes the 2 + 3 to be evaluated before the *, and the b or GetSomeBoolean() to be evaluated before the inner ==.

Copyright (c) 2003 Jeff Pang
Not affiliated or endorsed by Blizzard Entertainment
SourceForge.net Logo