#Noenv: Y: "" This Would Suppress The Warning

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

#Warn

;y := "" ; This would suppress the warning.


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.

You might also like