</head> <body> <h1>Var := expression</h1> <p>Evaluates an expression and stores the result in a <a href="../Variables.htm">variable</a>.</p> <pre class="Syntax">Var := expression</pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>Var</dt> <dd><p>The name of the <a href="../Variables.htm">variable</a> in which to store the result of <em>expression</em>.</p></dd> <dt>Expression</dt> <dd><p>See <a href="../Variables.htm#Expressions">expressions</a> and the examples below for details.</p></dd> </dl> <h2 id="Remarks">Remarks</h2> <p>The := operator is optimized so that it performs just as quickly as the = operator for simple cases such as the following:</p> <pre>x := y <em>; Same performance as x = %y%</em> x := 5 <em>; Same performance as x = 5.</em> x := "literal string" <em>; Same performance as x = literal string.</em></pre> <p>The words <code>true</code> and <code>false</code> are built-in constants containing 1 and 0. They can be used to make a script more readable as in these examples:</p> <pre>CaseSensitive := false ContinueSearch := true</pre> <p>It is possible to create a <a href="../misc/Arrays.htm#pseudo">pseudo-array</a> with this command and any others that accept an <em>OutputVar</em>. This is done by making <em>OutputVar</em> contain a reference to another variable, e.g. <code>Array%i% := Var/100 + 5</code>. See <a href="../misc/Arrays.htm">Arrays</a> for more information.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="../Variables.htm#Expressions">Expressions</a>, <a href="IfExpression.htm">If (expression)</a>, <a href="../Functions.htm">Functions</a>, <a href="SetEnv.htm">SetEnv</a>, <a href="EnvSet.htm">EnvSet</a>, <a href="EnvAdd.htm">EnvAdd</a>, <a href="EnvSub.htm">EnvSub</a>, <a href="EnvMult.htm">EnvMult</a>, <a href="EnvDiv.htm">EnvDiv</a>, <a href="IfEqual.htm">If (legacy)</a>, <a href="../misc/Arrays.htm">Arrays</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExString"> <p><a class="ex_number" href="#ExString"></a> Assigns a literal string to a variable.</p> <pre>Var := "literal string"</pre> </div> <div class="ex" id="ExNumber"> <p><a class="ex_number" href="#ExNumber"></a> Assigns a number to a variable.</p> <pre>Var := 3</pre> </div> <div class="ex" id="ExMath"> <p><a class="ex_number" href="#ExMath"></a> Calculates the net price and stores the result in <var>Var</var>.</p> <pre>Var := Price * (1 - Discount/100)</pre> </div> <div class="ex" id="ExBoolean"> <p><a class="ex_number" href="#ExBoolean"></a> Determines the truth of an expression and stores the result (1 for true or 0 for false) in <var>Finished</var>.</p> <pre>Finished := not Done or A_Index &gt; 100 if not Finished { FileAppend, %NewText%`n, %TargetFile% return } else ExitApp</pre> </div> </body> </html>