dudu5962 Posted August 9, 2010 Share Posted August 9, 2010 hi all, i know this kind of code is really bad but when compiling everything seems great, i mean there's no error but if you run the exe (launching the script will exit abnormaly but it is a bit hard to see in my example) it will say that $var is used without being declared #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("MustDeclareVars", 1) If(0) Then Local $var = 0 MsgBox(0, "", $var) Else MsgBox(0, "", $var) EndIf i understand why and i m not looking for how to make it work, for me it is a bug ... need to be reported Link to comment Share on other sites More sharing options...
Developers Jos Posted August 9, 2010 Developers Share Posted August 9, 2010 When the IF is not true the Local statement is not executes thus an error occurs. The compiler and au3check cannot figure this out since the code needs to be executed for this error to occur. the code should be: #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("MustDeclareVars", 1) Local $var = 0 If(0) Then MsgBox(0, "", $var) Else MsgBox(0, "", $var) EndIf 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...
dudu5962 Posted August 9, 2010 Author Share Posted August 9, 2010 i think the "mustdeclarevars" should warn me the if statement is not well managed with that Link to comment Share on other sites More sharing options...
czardas Posted August 9, 2010 Share Posted August 9, 2010 (edited) I think that there are so many possible ways to do things with autoit that it is very difficult to predict all types of error. If you tried to use the variable, I'm pretty sure that it would throw this error. The code you posted doesn't do anything with the variable, so there was no error.Edit: I misunderstood. It does throw an error when I run your code. Edited August 9, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Developers Jos Posted August 9, 2010 Developers Share Posted August 9, 2010 i think the "mustdeclarevars" should warn methe if statement is not well managed with thatGreat, but it is not a bug but a programmers error! 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...
dudu5962 Posted August 9, 2010 Author Share Posted August 9, 2010 Great, but it is not a bug but a programmers error!In a way i agree with you, writting this is really badwhat makes me think it s a bug is that by using "mustdeclarevars" it gives you error anytime you use vars without being declared.In the else statement it is not and it makes the program stop with an error. So in a way the compiler miss this error. it doesn't managed the if statement as it is executed(i must have made english error as it is not my language) Link to comment Share on other sites More sharing options...
Developers Jos Posted August 9, 2010 Developers Share Posted August 9, 2010 In a way i agree with you, writting this is really badwhat makes me think it s a bug is that by using "mustdeclarevars" it gives you error anytime you use vars without being declared.In the else statement it is not and it makes the program stop with an error. So in a way the compiler miss this error. it doesn't managed the if statement as it is executed(i must have made english error as it is not my language)The compiler only checks syntax (lexing) but does not run the script thus will never be able to detect a LOCAL statement being in the wrong place. 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...
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