This document discusses three warning modes in AutoHotkey:
1. UseEnv warns when an environment variable is used in place of an empty script variable. This can occur unexpectedly.
2. LocalSameAsGlobal warns for each undeclared local variable with the same name as a global before a script runs. This prevents errors from accessing globals within functions.
3. All applies the given warning mode to all supported warning types.
This document discusses three warning modes in AutoHotkey:
1. UseEnv warns when an environment variable is used in place of an empty script variable. This can occur unexpectedly.
2. LocalSameAsGlobal warns for each undeclared local variable with the same name as a global before a script runs. This prevents errors from accessing globals within functions.
3. All applies the given warning mode to all supported warning types.
This document discusses three warning modes in AutoHotkey:
1. UseEnv warns when an environment variable is used in place of an empty script variable. This can occur unexpectedly.
2. LocalSameAsGlobal warns for each undeclared local variable with the same name as a global before a script runs. This prevents errors from accessing globals within functions.
3. All applies the given warning mode to all supported warning types.
This document discusses three warning modes in AutoHotkey:
1. UseEnv warns when an environment variable is used in place of an empty script variable. This can occur unexpectedly.
2. LocalSameAsGlobal warns for each undeclared local variable with the same name as a global before a script runs. This prevents errors from accessing globals within functions.
3. All applies the given warning mode to all supported warning types.
x := y ; y hasn't been assigned a value. UseEnv: Warn when an environment variable is automatically used in place of an empty script variable. This sometimes occurs when an environment variable's name unexpectedly matches a variable used by the script. This warning occurs when the variable is accessed, but never occurs if the script enables #NoEnv (recommended for multiple reasons). #Warn ;#NoEnv ; Add this if "temp" is not intended to be an environment variable. ;EnvGet temp, TEMP ; This would copy the environment variable's value into the script variable. temp := "" ; Despite this line, temp still seems to have a value. MsgBox % temp ; This accesses the environment variable named "TEMP". LocalSameAsGlobal: Before the script starts to run, display a warning for each undeclared local variable which has the same name as a global variable. This is intended to prevent errors caused by forgetting to declare a global variable inside a function before attempting to access it. If the variable really was intended to be local, a declaration such as local x or static y can be used to suppress the warning. #Warn g := 1 ShowG() { ; The warning is displayed even if the function is never called. ;global g ; <-- This is required to access the global variable. MsgBox % g ; Without the declaration, "g" is an empty local variable. } All: Apply the given WarningMode to all supported warning types.