Jump to content

Recommended Posts

Posted (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 by czardas
Posted

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:

  Reveal hidden contents

 

Posted

@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 :)

Posted (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 by czardas
Posted

The subject @ScriptLineNumber in compiled scripts has been discussed many times. The forums search feature is your friend ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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

Posted

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.

  Reveal hidden contents

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)

userbar.png

Posted (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 by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

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)

userbar.png

Posted

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.

Posted

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.

  Reveal hidden contents

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)

userbar.png

  • Moderators
Posted

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=/so
Then 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

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,

Posted

Or use function _FileWriteLog. It automatically adds date and time to the log entries.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 6/22/2013 at 6:58 AM, michaelslamet said:

@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:

  Reveal hidden contents

 

Posted
  On 6/22/2013 at 7:21 AM, michaelslamet said:

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:

  Reveal hidden contents

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...