michaelslamet Posted June 22, 2013 Share Posted June 22, 2013 When our compiled script error, how to know which line that caused that error? Link to comment Share on other sites More sharing options...
czardas Posted June 22, 2013 Share Posted June 22, 2013 (edited) That depends on the type of error. If the error causes the interpreter to crash, I don't know a solution. If it is an exception you expect to occur, you could code for it using @ScriptLineNumber. You should first test everything thoroughly before compiling to avoid errors anyway. Edit Strike out Edited June 22, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
water Posted June 22, 2013 Share Posted June 22, 2013 Add error checking code to your script and test, test, test to find as much errors as possible before you use the script in production. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted June 22, 2013 Author Share Posted June 22, 2013 @czardas: thanks @ScriptLineNumber macro, I will look at it. @water and czardas: yes, I will But nobody know's what will happen in the future, let say when the PC upgrade the OS or upgrade the service pack or anything else Link to comment Share on other sites More sharing options...
czardas Posted June 22, 2013 Share Posted June 22, 2013 (edited) I just realised that @ScriptLineNumber doesn't work with compiled scripts. I'll test it and see. Edit I was right, it's no use - sorry for the misinformation. Edited June 22, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
water Posted June 22, 2013 Share Posted June 22, 2013 The subject @ScriptLineNumber in compiled scripts has been discussed many times. The forums search feature is your friend My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted June 22, 2013 Author Share Posted June 22, 2013 No problem, czardas, thanks for trying to help! So there is no way? Link to comment Share on other sites More sharing options...
czardas Posted June 22, 2013 Share Posted June 22, 2013 (edited) So you have to hard code the line numbers if you want to know where an error occurs when compiled using something like this. Global $sLine1 = "Line 1" SetError (1) ; Error induced for the demo If @error Then MsgBox(0, "", "Error occured at line 2") Exit ; or do something else EndIf Edited June 22, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
michaelslamet Posted June 22, 2013 Author Share Posted June 22, 2013 Unfortuntely for my scenario at this moment, it cant be done that way, because: 1. the script is 1000++ lines. 2. the error occure sometime, sometime not. It only throw an error when run as compiled and never when run from SciTe Link to comment Share on other sites More sharing options...
TheSaint Posted June 22, 2013 Share Posted June 22, 2013 This brings to mind the question, of why you would want to know, if the source script is no longer available to you? Surely, if the uncompiled script is available, you would always want to test with that, even doing compiles as needed during troubleshooting. Else, you should always code you programs to return errors at diligent/smart sections. One should never make presumptions when coding or rely on something not changing, so you should cater for most possibilities. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
michaelslamet Posted June 22, 2013 Author Share Posted June 22, 2013 @TheSaint: I have the source script with me It only throw an error when run as compiled and never when run from SciTe Thanks! Link to comment Share on other sites More sharing options...
TheSaint Posted June 22, 2013 Share Posted June 22, 2013 (edited) Missed your last post #9. One way, that I sometimes use, is to have certain values and returns, saved to a log file, that you can check if need be ... which can even be a ini file if desired. This method is especially useful where dialogs or SciTE is not helpful, etc. Edited June 22, 2013 by TheSaint Xandy 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
czardas Posted June 22, 2013 Share Posted June 22, 2013 Let's imagine the scenario that you used a macro such as @ScriptLineNumber in your code. When not compiled the value for @ScriptLineNumber will be different. So when compiled the script won't work as expected. The only way to fix such an error is to rewrite the code using methods that will work when you compile the script. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheSaint Posted June 22, 2013 Share Posted June 22, 2013 Sometimes, you just implement a manual switch in an ini file, to get the program to do error logging, which if it doesn't find, it doesn't do normally. I've even on occasion, implemented Screenshots, at key moments, to help detect things the eye misses ... especially when working with third party programs. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 22, 2013 Moderators Share Posted June 22, 2013 michaelslamet,water suggested you search the forum - let me save you the trouble as adding the text below is a single keypress. When compiling your script, run Obfuscator using the /STRIPONLY parameter. That way the compiler uses an au3 file which has the include files included, but all unused functions, variables, comments and blank lines removed. It is saved in the same folder as the source and named YourScriptName_Obfuscated.au3. You need to add these directives to the top of your script:#AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/soThen when the error occurs, it is easy to see which line gave the fault as it is this Obfuscated file which has been compiled - just scroll to the indicated location. The only problem we know of is that using the line continuation operator screws up the count, but apart from that it works fine. Of course, you need the full SciTE4AutoIt3 package, which you can download from here if you do not already use it. 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 Link to comment Share on other sites More sharing options...
silver217 Posted June 22, 2013 Share Posted June 22, 2013 add another 1000+ lines to your script: (I would use excel to do that) trace('1') .. trace('2') ... etc..... Func trace($x) $tracefile = fileopen(c:mytracefile.txt',1) FileWriteline($tracefile,$x) fileclose($tracefile) EndFunc enjoy, Link to comment Share on other sites More sharing options...
water Posted June 22, 2013 Share Posted June 22, 2013 Or use function _FileWriteLog. It automatically adds date and time to the log entries. TheSaint 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Mat Posted June 22, 2013 Share Posted June 22, 2013 Write a small script that reads each line and replaces @scriptlinenumber with the actual line number. Won't work with the @scriptlinenumber default value for a parameter trick. czardas 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
water Posted June 22, 2013 Share Posted June 22, 2013 @water and czardas: yes, I will But nobody know's what will happen in the future, let say when the PC upgrade the OS or upgrade the service pack or anything else That is why you usually test a script in different environments (operating system, versions of other applications the scripts automates (Office, Broser ...) etc.). Then you add this information to the Readme file so the user knows what to expect from your script. When a new OS is released and the script crashes then the user wouldn't be surprised. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted June 22, 2013 Share Posted June 22, 2013 It only throw an error when run as compiled and never when run from SciTe Can you please tell us which error messages you receive? Do they change or is it always the same? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - 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