Var := expression

Evaluates an expression and stores the result in a variable.

Var := expression

Parameters

Var

The name of the variable in which to store the result of expression.

Expression

See expressions and the examples below for details.

Remarks

The := operator is optimized so that it performs just as quickly as the = operator for simple cases such as the following:

x := y  ; Same performance as x = %y%
x := 5  ; Same performance as x = 5.
x := "literal string"  ; Same performance as x = literal string.

The words true and false are built-in constants containing 1 and 0. They can be used to make a script more readable as in these examples:

CaseSensitive := false
ContinueSearch := true

It is possible to create a pseudo-array with this command and any others that accept an OutputVar. This is done by making OutputVar contain a reference to another variable, e.g. Array%i% := Var/100 + 5. See Arrays for more information.

Expressions, If (expression), Functions, SetEnv, EnvSet, EnvAdd, EnvSub, EnvMult, EnvDiv, If (legacy), Arrays

Examples

Assigns a literal string to a variable.

Var := "literal string"

Assigns a number to a variable.

Var := 3

Calculates the net price and stores the result in Var.

Var := Price * (1 - Discount/100)

Determines the truth of an expression and stores the result (1 for true or 0 for false) in Finished.

Finished := not Done or A_Index > 100
if not Finished
{
    FileAppend, %NewText%`n, %TargetFile%
    return
}
else
    ExitApp