/AutoHotkey.docset/Contents/Resources/Documents/commands/_NoEnv.htm
https://gitlab.com/ahkscript/Autohotkey.docset · HTML · 32 lines · 29 code · 3 blank · 0 comment · 0 complexity · 5d922562f9267cae519dda6fd23e315f MD5 · raw file
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>#NoEnv</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <link href="../static/theme.css" rel="stylesheet" type="text/css" />
- <script src="../static/content.js" type="text/javascript"></script>
- </head>
- <body>
- <h1>#NoEnv <span class="ver">[v1.0.43.08+]</span></h1>
- <p>Avoids checking empty variables to see if they are environment variables (recommended for all new scripts).</p>
- <pre class="Syntax">#NoEnv</pre>
- <p>Specifying the line <code>#NoEnv</code> anywhere in a script prevents empty variables from being looked up as potential environment variables. For example:</p>
- <pre>#NoEnv
- MsgBox %WinDir%</pre>
- <p>The above would <strong>not</strong> retrieve the "WinDir" environment variable (though that could be solved by doing <code>WinDir := A_WinDir</code> near the top of the script).</p>
- <p>Specifying <code>#NoEnv</code> is recommended for all new scripts because:</p>
- <ol>
- <li>It significantly improves performance whenever empty variables are used in an expression or command. It also improves <a href="DllCall.htm">DllCall</a>'s performance when unquoted parameter types are used (e.g. int vs. "int").</li>
- <li>It prevents script bugs caused by environment variables whose names unexpectedly match variables used by the script.</li>
- <li>AutoHotkey v2 will make this behavior the default.</li>
- </ol>
- <p>To help ease the transition to #NoEnv, the built-in variables <a href="../Variables.htm#ComSpec">Comspec</a> and <a href="../Variables.htm#ProgramFiles">ProgramFiles</a> have been added. They contain the same strings as the corresponding environment variables.</p>
- <p>When #NoEnv is in effect, the script should use <a href="EnvGet.htm">EnvGet</a> to retrieve environment variables, or use built-in variables like <a href="../Variables.htm#WinDir">A_WinDir</a>.</p>
- <h3>Related</h3>
- <p><a href="EnvGet.htm">EnvGet</a>, <a href="../Variables.htm#ComSpec">Comspec</a>, <a href="../Variables.htm#ProgramFiles">ProgramFiles</a>, <a href="../Variables.htm#WinDir">A_WinDir</a></p>
- </body>
- </html>