nitekram Posted April 20, 2013 Share Posted April 20, 2013 (edited) I have passed my code to another co-worker and he said when he runs the script, he gets an ERROR on line 9544 - the problem, I have only 7100 lines in my script - I was wondering if there is a command/function, that I can put in my script to tell me what UDF file is creating the error? I am trying to drill it down, but was hoping that there was some indication within the error that would help - Line 9544 (File "path to exe"): Error: Variable used without being declared Edit: ps, I went through my code after adding Opt('MustDeclareVars', 1), and declared all my variables Edited April 20, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted April 20, 2013 Author Share Posted April 20, 2013 (edited) After running through my script and adding declarations for all variables - I had them run it again, and the line number has changed - wtf, cause I did not change any of the UDFs. New Line Number = 9548 EDIT - just found this, so let me see if I can get my answer from Edited April 20, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
water Posted April 20, 2013 Share Posted April 20, 2013 I remember that this has been discussed a few times. Best way to find the line is to use obfuscator to remove all lines Aut2Exe removes as well and then check the output file of obfuscator in your script directory. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
nitekram Posted April 20, 2013 Author Share Posted April 20, 2013 $hit, I meant to put it here, so sorry for the double post: EDIT: And here is the solution: ( I've tried to explain it as simply as I can, so even the beginners can understand it.) With the huge help from Jos, the goal in this post is now achieved, by using the (version 1.0.29.8 and above) and the /MergeOnly (or /MO) option. So, if you want to be able to find the errors reported by your compiled (EXE) scripts easily, you will need to add this line: #Obfuscator_Parameters=/mergeonly at the beginning of your script and run it through the Obfuscator (version 1.0.29.8 and above). The option in the line above will not do any obfuscation to your code. It will only merge all the included files into just one, called YourScriptInitialName_Obfuscated.au3. Now if you compile the obfuscated file, the error line numbers reported by your EXE file should match the lines in this obfuscated file. And once you find the right line of code, it should be a piece of cake to locate this line in your original source code. So make sure you keep this file somewhere for future error reference. IMPORTANT NOTE: You should pay attention to the messages that Obfuscator gives, or check the Obfuscator.log file after the process is completed for any messages like this one: -Line: 2. Encountered a continuationline which would be longer than 4095 when merge into 1 line, so spliting this continuation line into multiple lines.. If there is a similar line displayed, the line numbers from the error report and the obfuscated source will NOT match. In order to match them, you will need to merge any lines broken into smaller lines with the continuation character ("_") in the obfuscated source. But you will have to do that AFTER you have compiled your EXE file from that obfuscated script. Here is how the process works: 1. Add #Obfuscator_Parameters=/mergeonly at the beginning of your AU3 script 2. Obfuscate your AU3 script using the Obfuscator.exe (version 1.0.29.8 and above) 3. Compile the obfuscated script. 4. Check the Obfuscator.log file (it is in the same folder where the Obfuscator.exe is installed) for a line similar to the bulded one in the above text. 5. If no similar lines are found - you are good to go and the line numbers should match. 6. If there are similar lines, you will need to merge the lines splitted with the continuation ("_") character in order for your line numbers to match the number in the error report. If you come to the 6th point in the above list, you can either search for these lines manually, or you can use the following script to do the changes for you: If $CmdLine[0]=1 AND FileExists($CmdLine[1]) Then $SourceFileName=$CmdLine[1] Else $SourceFileName = FileOpenDialog("Specify the file to be processed", @ScriptDir, "AutoIt3 Script (*.au3)", 3) If @error Then Exit EndIf $ScriptData = Fileread($SourceFileName) ;Merge Continuation line into one line $ScriptData = StringRegExpReplace($ScriptData, "( _rn)", "") $TargetFileName = StringReplace($SourceFileName,".","_N.",-1) FileDelete($TargetFileName) FileWrite($TargetFileName, $ScriptData) 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
water Posted April 20, 2013 Share Posted April 20, 2013 You got your answer and could solve the problem? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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