Factfinder Posted April 13, 2014 Posted April 13, 2014 I have a script, both .au3 and the compiled version run fine on my computer (Win 7 x64). I tried to use the compiled version on another (Win 7 x64) system and got: Line 1208 (File" C:script.exe") Error: Variable used without being declared Knowing the line number is not much of help when the script is compiled. It could be handy to know the variable too. I know if I declare all the variables in the script the error will go. But is there any way to add some lines to autoit error report so it report the variable too?
DatMCEyeBall Posted April 13, 2014 Posted April 13, 2014 Post the script or a reproducer so we can have a look at the code. "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
Moderators Melba23 Posted April 13, 2014 Moderators Posted April 13, 2014 Factfinder, I know if I declare all the variables in the script the error will goIf you use SciTE4AutoIt3 you can run Au3Check on your script before compiling and locate the undeclared variables very easily. You can download the expanded editor from here - the package also contains lots of other utilities to help you code in AutoIt. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Factfinder Posted April 13, 2014 Author Posted April 13, 2014 Post the script or a reproducer so we can have a look at the code. The script is really a long one and I think the question is a general one. Thank you. Factfinder, If you use SciTE4AutoIt3 you can run Au3Check on your script before compiling and locate the undeclared variables very easily. You can download the expanded editor from here - the package also contains lots of other utilities to help you code in AutoIt. M23 Thank you M23. I have already run the check on uncompiled script. Normally it will detect the undeclaired variables but not in this case. I know adding AutoItSetOption("MustDeclareVars", 1) will show all the undeclaired variables, but I have many variables that are implicitely declaired. My question is if there is a way to get the undeclaired variable in a compiled script. Perhaps I should make a feature request to script autoit error so that the variable will be named along with the line number like: Line 1208 (File" C:script.exe") Error: Variable ($aVar) used without being declared
Moderators Melba23 Posted April 13, 2014 Moderators Posted April 13, 2014 Factfinder,If you compile the script using Au3Stripper then SciTE4AutoIt3 removes all the blank lines and unused functions/variables before compiling the stripped file. You can then compare the number returned by the complied error MsgBox directly with that file and so find the errant variable. Although if you cannot see it when you run Au3Check within SciTE, that means it is almost certainly within an include file. Are you using any non-standard includes? I would certainly check them first. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Factfinder Posted April 13, 2014 Author Posted April 13, 2014 Thanks for the reply M23. You are right. I have indeed a couple of non-standard includes and most probably one of the them causes the issue. I will check them. Thank you. If you compile the script using Au3Stripper then SciTE4AutoIt3 removes all the blank lines and unused functions/variables before compiling the stripped file. You can then compare the number returned by the complied error MsgBox directly with that file and so find the errant variable. The Au3Stripper should be the new replacement for Obfuscators /StripOnly Function. I have not tried it yet, but will certaily do. Apart from that the feature request is still on: My question is if there is a way to get the undeclaired variable in a compiled script. Perhaps I should make a feature request to script autoit error so that the variable will be named along with the line number like: Line 1208 (File" C:script.exe") Error: Variable ($aVar) used without being declared
Chimaera Posted April 14, 2014 Posted April 14, 2014 (edited) I get this quite a bit from includes as well And i dont very often run non standard ones Its a shame it cant say which include its from to be able to narrow it down often i get the the cannot declare variable already used or something like that Edited April 14, 2014 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
BrewManNH Posted April 14, 2014 Posted April 14, 2014 often i get the the cannot declare variable already used or something like that That's a completely different issue than the one the OP posted, this is probably happening because you're using non-standard includes along with the standard and variable names are being reused in one of them. This should be picked up by Au3Check before you compile it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Bearpocalypse Posted April 14, 2014 Posted April 14, 2014 Factfinder, If you use SciTE4AutoIt3 you can run Au3Check on your script before compiling and locate the undeclared variables very easily. You can download the expanded editor from here - the package also contains lots of other utilities to help you code in AutoIt. M23 Well look at that. I had the same error and updating to the latest SciTE fixed it for me. YAY! for Melba!
Moderators Melba23 Posted April 15, 2014 Moderators Posted April 15, 2014 Bearpocalypse,More like YAY! for Jos - he maintains the SciTE4AutoIt3 package.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
javygonx Posted May 25, 2016 Posted May 25, 2016 (edited) This may or may not helped. But the same issue happened to me. On my local PC runs fine and the executable file failed with same error on other PCs. But I believe I found the solution;. If you have Visual Studio installed on the PC then it will run sucesfully without the error. I thought installing AutoIT will install any of the libraries; but its not. Im still looking around to see which of the redistribution libraries from Microsoft; (C++ or VB)..... will have the files needed to fix this issue. Edited May 25, 2016 by javygonx
BrewManNH Posted May 25, 2016 Posted May 25, 2016 @javygonx if you compile the script, you won't have this issue and won't need to install anything. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
javygonx Posted May 25, 2016 Posted May 25, 2016 3 hours ago, BrewManNH said: @javygonx if you compile the script, you won't have this issue and won't need to install anything. Yes; I compile it and no errors found. I ran the .exe file on my local PC and works great. I ran the .exe file on a different PC with VisualStudio and it runs fine; I ran the .exe file in a PC without VisualStudio and it FAILED with the error!.. Weird!
AutoBert Posted May 25, 2016 Posted May 25, 2016 Just post the script (or a runable reproducer which same issue)
fopetesl Posted August 21, 2017 Posted August 21, 2017 I have the same problem with undeclared variable on a line (Line 52) beyond my script length. It's pretty simple: #include <MsgBoxConstants.au3> Opt("MustDeclareVars", 1) Opt("TrayAutoPause", 0) #NoTrayIcon #RequireAdmin #AutoIt3Wrapper_Run_Au3Stripper y #Au3Stripper_Parameters=/MO /RSLN #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 Opt("TrayIconHide", 1) ; Set the working directory ... or set PATH! ... ; Local $BatchDir = "C:\S3_GUI\ncat" ;Local $BatchDir = "C:\S3_GUI\FINAL" If Not IsDeclared($BatchDir) Then Global $BatchDir $BatchDir = "C:\S3_GUI\ncat" FileChangeDir($BatchDir) Local $nPINfile = FileOpen("OurPIN.sav", $FO_OVERWRITE) Local $sPasswd = FileRead($nPINfile) FileClose($nPINfile) MsgBox(0, "", "PIN_Unlock: " & $sPasswd) Local $regresult = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.sf8", "accept", "REG_SZ", "$sPasswd") exit 0 It runs without problem using F5 but when compiled to run as an exe it throws the error. I cannot find the Stripper file nor its ini to locate the 'stripped' file. The most powerful number in the Universe. Zero.
BrewManNH Posted August 21, 2017 Posted August 21, 2017 35 minutes ago, fopetesl said: It runs without problem using F5 No, it doesn't. 35 minutes ago, fopetesl said: but when compiled to run as an exe it throws the error. Because IsDeclared needs an expression, you fed it the name of a variable. ;~ This is wrong If Not IsDeclared($BatchDir) Then Global $BatchDir ;~ This is right If Not IsDeclared("BatchDir") Then Global $BatchDir If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
fopetesl Posted August 21, 2017 Posted August 21, 2017 (edited) Still not work: If Not IsDeclared("C:\S3_GUI\ncat") Then Global $BatchDir $BatchDir = "C:\S3_GUI\ncat" OK, you missed my clumsy error! #include <FileConstants.au3> #include <WinAPIFiles.au3> DUH! Edited August 21, 2017 by fopetesl The most powerful number in the Universe. Zero.
BrewManNH Posted August 21, 2017 Posted August 21, 2017 You don't pay attention much do you? Read what I wrote again, and if it's still not clear, read the help file for IsDeclared. You are doing it 100% wrong. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Developers Jos Posted August 21, 2017 Developers Posted August 21, 2017 3 hours ago, fopetesl said: #AutoIt3Wrapper_Run_Au3Stripper y Talking about errors: This will also give an error when you Compile.... right? Jos 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.
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