/AutoHotkey.docset/Contents/Resources/Documents/commands/SetEnv.htm

https://gitlab.com/ahkscript/Autohotkey.docset · HTML · 43 lines · 35 code · 8 blank · 0 comment · 0 complexity · 74f28b7ea81763366bffb77fcdc258c4 MD5 · raw file

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>SetEnv</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  8. <script src="../static/content.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <h1>SetEnv (Var = Value)</h1>
  12. <p>Assigns the specified value to a <a href="../Variables.htm">variable</a>.</p>
  13. <pre class="Syntax">SetEnv, Var, Value
  14. Var = Value</pre>
  15. <h3>Parameters</h3>
  16. <dl>
  17. <dt>Var</dt>
  18. <dd><p>The name of the <a href="../Variables.htm">variable</a> in which to store <em>Value</em>.</p></dd>
  19. <dt>Value</dt>
  20. <dd><p>The string or number to store. If the string is long, it can be broken up into several shorter lines by means of a <a href="../Scripts.htm#continuation">continuation section</a>, which might improve readability and maintainability.</p></dd>
  21. </dl>
  22. <h3>Remarks</h3>
  23. <p>By default, any spaces or tabs at the beginning and end of <em>Value</em> are omitted from <em>Var</em>. To prevent this, use the methods described at <a href="AutoTrim.htm#Off">AutoTrim Off</a>.</p>
  24. <p>The name &quot;SetEnv&quot; is misleading and is a holdover from 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 the size of each environment variable to 32 KB. Use <a href="EnvSet.htm">EnvSet</a> instead of SetEnv to write to an <a href="../Variables.htm#env">environment variable</a>.</p>
  25. <p>The memory occupied by a large variable can be freed by setting it equal to nothing, e.g. <code>Var =</code>.</p>
  26. <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>OuputVar</em> contain a reference to another variable, e.g. <code>array%i% = 123</code>. See <a href="../misc/Arrays.htm">Arrays</a> for more details.</p>
  27. <h3>Related</h3>
  28. <p><a href="AutoTrim.htm">AutoTrim</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</a>, <a href="../misc/Arrays.htm">Arrays</a></p>
  29. <h3>Example</h3>
  30. <pre class="NoIndent">Var1 = This is a string.
  31. Color2 = 450
  32. Color3 = %Var1%
  33. Array%i% = %A_TICKCOUNT%</pre>
  34. </body>
  35. </html>