JohnOne Posted January 23, 2010 Share Posted January 23, 2010 Not sure if this is the correct place, so I apologise if it is. I just observed autoit3 script behaviour I have never seen before after recieving an error. The error was "variable used without being declared" Normally when I recieve an error like this, the script exits after confirming the dialogue box, but it did not this time, it just paused it, and carried on after I unpaused it. Just wondering if its normal ? v3.3.4.0 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 23, 2010 Share Posted January 23, 2010 Were you running or compiling it from SciTE? Can you post a short script and the conditions to run it under that reproduces the issue? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnOne Posted January 23, 2010 Author Share Posted January 23, 2010 (edited) The actuall code is to large to post up here, and Its not my work so dont have permission to post anyway. But heres what it was doing when it happened Local $avar1[3][3] = [[2, 3, 4],[0, 1, 2],[5, 6, 7]] ;these are gotten from an ini file that does not get altered by the code. Local $ivar = 1 For $i = 0 To UBound($avar1) - 1 If $ivar >= $avar1[$i][0] And $ivar <= $avar1[$i][1] Then $ivar2 = $avar1[$i][2] EndIf Next Switch $ivar2 Case $ivar2 = 4 MsgBox(0,"","Four") Case $ivar2 = 2 ;error was here, $ivar2 used without being declared MsgBox(0,"","Two") Case $ivar2 = 7 MsgBox(0,"","Seven") Case Else MsgBox(0,"","None") EndSwitch It happened twice, but over a period of a few hours while the script was running. I was actually testing the script on 3.3.4.0 with a fresh install of it on another laptop, before upgrading my 3.3.2.0 on my desktop. EDIT: was running uncompiled from double click .au3. Edited January 23, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 23, 2010 Share Posted January 23, 2010 In general, we don't want the original script posted to the forum. A short demo that has the same issue is always preferred. Check variable scopes. You used LOCAL in your example. Make sure the declaration is within the scope of the code that uses the variable. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnOne Posted January 24, 2010 Author Share Posted January 24, 2010 I agree with both posts, and see what should be done as good practice But this post is not about that, it is about the pausing and not exiting of the script. Ive just never seen it before, and thought I'd mention it. I thought it was pretty cool, and had hoped it was a great new addition to autoit3. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 24, 2010 Share Posted January 24, 2010 Well, first of all good catch for Thanubis. I didn't pay any attention to that Switch/Case syntax at all. The effect of using compares in the Switch Case was to get the Boolean result of the compare "$ivar = 7", and then check if that True/False matched $ivar (because it was the Switch variable). There might be some use in that, but it would be twisted. As for the failure message, there is another version: "WARNING: $ivar: possibly used before declaration." The "possibly" version of this message is not fatal. Here is an example script that causes it: _TestFunc(True) ConsoleWrite("$TestVar = " & $TestVar & @LF) Func _TestFunc($Input) Global $TestVar = $Input EndFunc Bad practice to declare Globals in conditional statement or functions (which may or may not have run before use of the variable), but not fatal as long as something DOES declare it before use. Also bad practice, but not fatal: Assign("TestVar", True, 2) ConsoleWrite("$TestVar = " & $TestVar & @LF) This version is fatal because the variable is not declared anywhere before use: _TestFunc(True) ConsoleWrite("$TestVar = " & $TestVar & @LF) Func _TestFunc($Input) ; Do nothing EndFunc So maybe you dropped the word "possibly" out of your error message? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnOne Posted January 24, 2010 Author Share Posted January 24, 2010 Yes probably, that makes total sense PsaltyDS. Thanks for you time to explain. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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