Assigns the specified value to a variable.
SetEnv, Var, Value Var = Value |
Parameters
Var | The name of the variable in which to store Value. |
Value | The string or number to store. If the string is long, it can be broken up into several shorter lines by means of a continuation section, which might improve readability and maintainability. |
Remarks
By default, any spaces or tabs at the beginning and end of Value are omitted from Var. To prevent this, use AutoTrim Off beforehand. However, `t (the tab character) is unconditionally omitted. To prevent this, use %A_Tab% in place of `t.
The name "SetEnv" is misleading and is used only for backward compatibility with AutoIt v2. Unlike AutoIt v2, AutoHotkey does not store its variables in the environment. This is because performance would be worse and also because the OS limits such variables to 32K. Use EnvSet instead of SetEnv to write to an environment variable.
The memory occupied by a large variable can be freed by setting it equal to nothing, e.g. var =
It is possible to create an array with this command and any others that accept an OutputVar. This is done by making OuputVar contain a reference to another variable, e.g. array%i% = 123. See Arrays for more details.
Related
AutoTrim, EnvSet, EnvAdd, EnvSub, EnvMult, EnvDiv, If, Arrays
Example
Var1 = This is a string.
Color2 = 450
Color3 = %Var1%
Array%i% = %A_TICKCOUNT%