Jump to content
Sign in to follow this  
chad.stout

Call a function if your script breaks?

Recommended Posts

chad.stout

Hey, just wondering if there is a way to call a specified function on the event of a script haulting due to an error in the code (e.g. a function that dumps all current data into a log file).

Thanks,

-Chad

Share this post


Link to post
Share on other sites
lod3n

Search the Forum for "RunErrorsFatal" and "AutoIt.Error" if you are using COM.

There is no automatic way to dump the values of your variables into a file, you'd really have to do that manually as you go. Also search for "assert", some people have made some nifty assertion functions which could be adapted to that purpose.

The best thing you can do is develop with Scite, and pump messages into it's console.

Also, don't make assumptions about the state of your variables. For instance, if you run a function that is supposed to return an array of a specific size, before you go any further, test it by running it through IsArray, and make sure it's Ubound is what you expect. It takes longer, but it makes your code much more bulletproof.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites
chad.stout

Search the Forum for "RunErrorsFatal" and "AutoIt.Error" if you are using COM.

There is no automatic way to dump the values of your variables into a file, you'd really have to do that manually as you go. Also search for "assert", some people have made some nifty assertion functions which could be adapted to that purpose.

The best thing you can do is develop with Scite, and pump messages into it's console.

Also, don't make assumptions about the state of your variables. For instance, if you run a function that is supposed to return an array of a specific size, before you go any further, test it by running it through IsArray, and make sure it's Ubound is what you expect. It takes longer, but it makes your code much more bulletproof.

Heh thanks for that!

I do take many precautions to ensure the script runs properly, but it's already at 8K lines, and only about 2/3 done :/ Coupled with fat fingers, the script tends to break every so often.

Thanks again,

-Chad

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.