Valik Posted January 10, 2006 Share Posted January 10, 2006 tylo, with the addition of @COM_EventObj, a macro can now be used as a COM object. Currently Au3Check throws an error when trying to access a property/method on a macro-COM-object. Link to comment Share on other sites More sharing options...
PartyPooper Posted January 11, 2006 Share Posted January 11, 2006 (edited) Tylo, love the new declared but not used function of AU3Check v1.49. It helped me clean up my code, however, I found AU3Check comes up with the following warning from the standard library: C:\Program Files\AutoIt3\Include\Inet.au3(181,26) : WARNING: $i_ReturnErrorCode: declared, but not used in func. and C:\Program Files\AutoIt3\Include\Inet.au3(182,25) : WARNING: $i_LocalErrorCode: declared, but not used in func. From what I can determine, AU3Check is correctly putting out warnings for these because they aren't used (as far as I can see). I won't put in a bug report on Inet.au3 unless you think its warranted. Edit: corrected brainfart Edited January 11, 2006 by PartyPooper Link to comment Share on other sites More sharing options...
Valik Posted January 11, 2006 Share Posted January 11, 2006 Tylo, love the new declared but not used function of AU3Check v1.49. It helped me clean up my code, however, I found AU3Check comes up with the following warning from the standard library:C:\Program Files\AutoIt3\Include\Inet.au3(181,26) : WARNING: $i_ReturnErrorCode: declared, but not used in func.and C:\Program Files\AutoIt3\Include\Inet.au3(182,25) : WARNING: $i_LocalErrorCode: declared, but not used in func.From what I can determine, AU3Check is correctly putting out warnings for these because they aren't used (as far as I can see). I won't put in a bug report on Inet.au3 unless you think its warranted.Edit: corrected brainfartYou're going to find tons of warnings of this nature generated from the standard library. Date.au3 is particularly bad. Link to comment Share on other sites More sharing options...
PartyPooper Posted January 11, 2006 Share Posted January 11, 2006 Yeah, so I've since found out I've re-installed v1.48 for general coding use and will only use v1.49 when I want to specifically clean up my own code. BTW, I did edit the au3check.dat file and change the second last line to %TrayItemSetOnEvent 2 <UDF>, but v1.49 was still throwing the same error afterwards. Link to comment Share on other sites More sharing options...
MHz Posted January 11, 2006 Share Posted January 11, 2006 I did edit the au3check.dat file and change the second last line to %TrayItemSetOnEvent 2 <UDF>, but v1.49 was still throwing the same error afterwards.You need to edit the file in Defs\unstable\Au3Check. CompileAu3 conditionally chooses Prod or Beta Dat files. @Tylo Au3Check seems to have a big dislike for the counter variable used in For loops. Declaring the counter seems useless also to suppress. Added example below. Func _Test() Local $i For $i = 1 To 10 $i = 9 Next EndFunc With Local $i WARNING: $i: declared, but not used in func. Local $i ~~~~~~~~^ Without Local $i WARNING: $i: declared, but not used in func. For $i = 1 To ~~~~~~~~~~~^ It has problems with Messageloops with GuiGetMsg(). Another example of unknown reasoning to suppress. Local $msg does not help. WARNING: $msg: declared, but not used in func. $msg = GUIGetMsg() ~~~~~~~~~~~~~~~~~~^ That is only checking so far. It also picks on unused Gui Control handles which I prefer to leave in for when I can add to them. Let's be reasonable. I don't think my scripting is that bad . I see no use for these new warnings unless the script was final without doubt of continuing. Selection of simply turning off these warnings seems impossible ATM with CompileAu3. I may need to go back from v1.49 also to avoid these new warnings. Link to comment Share on other sites More sharing options...
Valik Posted January 11, 2006 Share Posted January 11, 2006 I think new warnings need to be disabled by default. I had to alter two of my scripts which were using Au3Check programmatically just to suppress this new warning and restore 1.48 behavior. I like the new warning but it's not practical for me to use it yet because a lot of AutoIt's libraries are not compatible yet. Also, like MHz, I sometimes write GUIs and assign IDs to variables and never use them but I want them to remain so that they are there if I need them. Link to comment Share on other sites More sharing options...
tylo Posted January 11, 2006 Author Share Posted January 11, 2006 Ok, I'll disable the warning by default. MHz's _Test() function only assigns values to $i - it never actually uses it in an expression. But it incorrectly throws a warning, because in a For loop you may use the control variable simply as a counter to repeat N times, without accessing $i inside the loop. Will fix that too.I could relax it somewhat, so code like this does not throw a warning:Local $var $var = 1I.e. declaration alone will produce warning, but an additional assignment to it will count as usage (although it is not). Will at least consider it.v1.50 will treat @COM_EventObj as a COM variable, and allow COM method/attributes calls on it. If it is likely that more macros will become COM object, I should either allow to add entries in the .dat file (more work), or open for every macro to be accessed as COM objects. blub Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2006 Developers Share Posted January 11, 2006 You're going to find tons of warnings of this nature generated from the standard library. Date.au3 is particularly bad.Ok Ok Ok Valik ... I get the HINT Will do some cleanup of the code when time permits.... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valik Posted January 11, 2006 Share Posted January 11, 2006 tylo, I have a feature request. I personally hate Dim and think it's a bad idea to use it because it has a variable scope (Re-uses Global if found, otherwise Local). I would love a -w 6 which throws a warning when Dim is used. IMO, Dim should be deprecated out of AutoIt but failing that, at least it should be discouraged heavily in favor of the more explicit scope declarators. I digress, a -w 6 "Warn when using Dim" feature would be nice. Link to comment Share on other sites More sharing options...
jpm Posted January 11, 2006 Share Posted January 11, 2006 as I understand the new au3Check need the MSVCP80.dll and MSVCR80.dll so I cannot run it on a XP/Sp2. My question is does that will stay? if yes does those will be package with Scite delivery or au3Check Link to comment Share on other sites More sharing options...
tylo Posted January 12, 2006 Author Share Posted January 12, 2006 (edited) Version 1.50!added: accept @COM_EventObj as a COM object. You can add macros to the .dat file that are accepted as COM object like: *COM_EventObj. @COM_EventObj must be added previously too.fixed: ReDim not allowed as variable declarator and initialization is not allowed.fixed: -u usedsym.txt now includes functions referenced as "callbacks".new option: -U unusedsym.txt creates a list of defined, but not used global symbols.warning option: -w 5 (warn on unused local variables. No warning for variables assigned to after declaration). Default off.warning option: -w 6 (warn on unused local variables. Stricter than -w 5). Default off.warning option: -w 7 (warn when using Dim as variable declarator. Note that no warning is issued when Dim is used on an existing variable, because Dim is then an "operator" like ReDim, and not a declarator). Default off.compiled with VC++ 6.Cheers. Edited January 12, 2006 by tylo blub Link to comment Share on other sites More sharing options...
Valik Posted January 12, 2006 Share Posted January 12, 2006 Very nice, tylo. The behavior for Dim went above what I expected. I think -w 5 still needs a small tweak, though. Both of these are equivalent, IMO, but only the second example passes Au3Check: Local $var = StringSplit("", "") Local $var $var = StringSplit("", "") Function calls can have side effects (Modify a global variable, set @error/@extended), so maybe unused declarations that are assigned values from function calls shouldn't be flagged at all. Link to comment Share on other sites More sharing options...
tylo Posted January 12, 2006 Author Share Posted January 12, 2006 -w 5 is a quasi check, but warns on declared (and possible initialized) only variables, like in your first example. Your second code actually accesses $var again by assigning to it (but it is still not used), so it let it pass.-w 5 in v1.49 is now -w 6, and is stricter.Function calls can have side effects (Modify a global variable, set @error/@extended), so maybe unused declarations that are assigned values from function calls shouldn't be flagged at all.Only local variables are warned on, so unused declared local variables cannot be modified by a different function as a side effect. You'll have to pass it as a ByRef, and in that case it will be used, and no warnings are issued. blub Link to comment Share on other sites More sharing options...
Valik Posted January 12, 2006 Share Posted January 12, 2006 Only local variables are warned on, so unused declared local variables cannot be modified by a different function as a side effect. You'll have to pass it as a ByRef, and in that case it will be used, and no warnings are issued.You didn't quite understand what I meant (Which is to be expected since I didn't explain it very well). Until I can explain it better or find a good example that demonstrates what I mean, I'll just drop it for now. Link to comment Share on other sites More sharing options...
jpm Posted January 12, 2006 Share Posted January 12, 2006 Nice job Tylo, Do I have an option to output the working lines? I mean excluding the non referenced functions/variables Link to comment Share on other sites More sharing options...
Valik Posted January 12, 2006 Share Posted January 12, 2006 (edited) Ok Ok Ok Valik ... I get the HINT Will do some cleanup of the code when time permits....All my scripts now cleanly pass "-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7". IMO, the standard library files should, too. Here is how I (somewhat quickly) cleaned up all my library files. I used the following batch file: @Echo OFF FOR %%F IN (*.au3) DO "D:\Program Files\SciTE\Au3Check\Au3Check.exe" -q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 "%%F" Place that file in the same directory as the library files, then load the batch file into SciTE. I used Tools->Go on the file and it ran Au3Check on every file and printed only the warnings/errors to the Output pane. Double-clicking an error will load the correct file and jump to the line. Just for a test, I ran the file on the Include library. _ArrayCreate() can be made to pass cleanly like this: Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0) Local $i_UBound = @NumParams Local $av_Array[$i_UBound] Local $i_Index For $i_Index = 0 To ($i_UBound - 1) $av_Array[$i_Index] = Eval("v_" & String($i_Index)) Next Return $av_Array ; Create fake usage for the variables to suppress Au3Check -w 6 $v_0 = $v_0 = $v_1 = $v_2 = $v_3 = $v_4 = $v_5 = $v_6 = $v_7 = $v_8 = $v_9 = $v_10 $v_11 = $v_11 = $v_12 = $v_13 = $v_14 = $v_15 = $v_16 = $v_17 = $v_18 = $v_19 = $v_20 EndFunc;==>_ArrayCreate After fixing the above, from the looks of it, there are only about 50 - 60 warnings/errors. I just fixed about that many myself to get 34 library and 28 scripts running cleanly in less than an hour. Have fun! Edited January 12, 2006 by Valik Link to comment Share on other sites More sharing options...
Developers Jos Posted January 12, 2006 Developers Share Posted January 12, 2006 All my scripts now cleanly pass "-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7". IMO, the standard library files should, too. Here is how I (somewhat quickly) cleaned up all my library files. I used the following batch file: @Echo OFF FOR %%F IN (*.au3) DO "D:\Program Files\SciTE\Au3Check\Au3Check.exe" -q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 "%%F" Place that file in the same directory as the library files, then load the batch file into SciTE. I used Tools->Go on the file and it ran Au3Check on every file and printed only the warnings/errors to the Output pane. Double-clicking an error will load the correct file and jump to the line. Just for a test, I ran the file on the Include library. _ArrayCreate() can be made to pass cleanly like this: Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0) Local $i_UBound = @NumParams Local $av_Array[$i_UBound] Local $i_Index For $i_Index = 0 To ($i_UBound - 1) $av_Array[$i_Index] = Eval("v_" & String($i_Index)) Next Return $av_Array ; Create fake usage for the variables to suppress Au3Check -w 6 $v_0 = $v_0 = $v_1 = $v_2 = $v_3 = $v_4 = $v_5 = $v_6 = $v_7 = $v_8 = $v_9 = $v_10 $v_11 = $v_11 = $v_12 = $v_13 = $v_14 = $v_15 = $v_16 = $v_17 = $v_18 = $v_19 = $v_20 EndFunc;==>_ArrayCreate After fixing the above, from the looks of it, there are only about 50 - 60 warnings/errors. I just fixed about that many myself to get 34 library and 28 scripts running cleanly in less than an hour. Have fun! I have started cleaning them .... I am always running the below script automagically before uploading the UDF lib to ensure there are no errors and will add the check for unused vars to the automated process.... ;test udfs #include-once opt("MustDeclareVars",1) #include <GUIConstants.au3> #include <array.au3> #include <color.au3> #include <date.au3> #include <file.au3> #include <inet.au3> #include <math.au3> #include <misc.au3> #include <process.au3> #include <string.au3> #include <visa.au3> #include <GUIlist.au3> #include <GUIlistView.au3> #include <GuiCombo.au3> #include <GuiTab.au3> #include <GuiEdit.au3> #include <GuiSlider.au3> #include <GuiTreeView.au3> $test=0; <- trigger at least 1 warning Thanks for the input.. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PartyPooper Posted January 13, 2006 Share Posted January 13, 2006 Any plans for SciTE to have a GUI AU3Check Config (something like the SciTE Config) so that Au3Check options can be turned off and on at will? Or do you think that may lead to an increase in false bug reports because noobs (like me) have used the wrong options? Link to comment Share on other sites More sharing options...
tylo Posted January 13, 2006 Author Share Posted January 13, 2006 It shouldn't be a necessary for all library code to pass all warning test, IMO. For example where Eval() is used (e.g in ArrayCreate), you'll have to make dummy code (as Valik showed) to avoid them. A warnings flags that there may be a logical error or unclean code, but it may also be perfectly correct code.jpm: I intended to add file and line references to where symbols are defined, but forgot it. You'll have to wait for next release. However, I now have concerns for how useful the -u and -U options are, because they can not detect usage of functions and variables accessed via Call($fnName) and Eval($varName). That's the downside of introducing such flexible functionality. au3check is clever enough to detect usage of callback functions set in e.g. AdlibEnable("myadlib"), as long as the function names are given as string literals, which is normally the case - but not so for Call() and Eval().The other concern is how to utilize the produced lists to remove unused code. When I add file and line reference to definitions of the symbols, it should be easy to exclude non-used functions by simply cutting the lines where these are defined. However, global variables are more tricky. Valik's concerns with unused vars initialized with a function, put me on the track. E.g. in Global $g_app, $g_status = MyInit()$g_status may not be used by any code, but MyInit() must for sure be called, so you cannot simply remove the line. That would also falsely remove the $g_app declaration. In any case, when multiple variables are declared on the same line, the line probably must be batch edited to remove certain declarations.So there are two cases where you should keep lines of code containing unused variable declarations:1) When multiple global variables are declared on one line, and some are unused, don't bother to remove certain variable declarations - just keep the line.2) When a variable is initialized with an expression that contains a function call, I will not mark that variable as unused as of next version (even though it may not never be used), because the function call itself must be retained. I.e the line will be kept. blub Link to comment Share on other sites More sharing options...
jpm Posted January 13, 2006 Share Posted January 13, 2006 @tylo That the reason I was mentioning to have an escape mechanism with a directive to force to keep a function or a variable. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now