Search the Community
Showing results for tags 'au3check_parameters=-q -d'.
-
It is not completely uncommon, e.g. in beginner scripts, that variables will be declared within a conditional statement (more precisely in only one part of the statement). A standard hint is to use Opt("MustDeclareVars", 1) or even #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 According to the help, the parameter -d should be identical with Opt("MustDeclareVars", 1). In the following script, however, these two alternatives show a different behavior when you declare a variable inside a conditional statement : ; ------ > Comment out 1. or 2. ; 1. #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 ; Info : -d as Opt("MustDeclareVars", 1) ; 2. ;~ Opt("MustDeclareVars", 1) ; Info : 1=Vars must be declared ConsoleWrite("+ ===> _Example(True) : " & @CRLF) _Example(True) ConsoleWrite("+ ===> _Example(False) : " & @CRLF) _Example(False) Func _Example($bValue) ; Local declaration of $sString inside If : If $bValue Then Local $sString = "Text IF" Else $sString = "Text ELSE" EndIf ConsoleWrite("> bValue = " & $bValue & " sString = " & $sString & @CRLF & @CRLF) EndFunc ;==>_Example --> 1. Console output #AutoIt3Wrapper_Au3Check_Parameters : + ===> _Example(True) : > bValue = True sString = Text IF + ===> _Example(False) : > bValue = False sString = Text ELSE +>23:50:49 AutoIt3.exe ended.rc:0 --> 2. Console output Opt("MustDeclareVars", 1) : + ===> _Example(True) : > bValue = True sString = Text IF + ===> _Example(False) : "C:\BS_AutoIt\Projekte\Testprogramme\MustDeclare-TEST.au3" (50) : ==> Variable used without being declared.: $sString = "Text ELSE" ^ ERROR ->23:59:19 AutoIt3.exe ended.rc:1 ==> This happens when starting the script with Run (F5). Compile and Build do not show any warnings. Using just $g_sStr = "" without declaration generates the warning 'possibly not declared/created yet' in both variants. ;~ #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 Opt("MustDeclareVars", 1) $g_sStr = "" Did I miss something?