Sign in to follow this  
Followers 0
bobsobol

Opt("OnExitFunction",?)

3 posts in this topic

I'm trying to make an OnExitFunction which cleans up the temporary files it created if it finds half way through that it can't process the rest. Insufficient file/directory privaliges can cause this, and it's not just a matter of being an Admin. I can't test for it before I've created the Temporary files, because they will determine what directories and files you need to have write privalages for. My script will become very large if I need to write cleanup code for all the places it might fail so an OnExitFunction is ideal. (GoTo would do but it's only for onerror GoTo)

Trouble is all the other Opt() functions need an Option name as String and a parameter as number. How do I set the parameter of Opt() for the "OnExitFunction" option? The help files description:-

OnExitFunc Sets the name of the function called when AutoIt exits (default is OnAutoItExit).

Isn't particulaly helpful as the line:-

Opt("OnExitFunction",OnAutoItExit)

or

Opt("OnExitFunction","OnAutoItExit")

Fails too. :lmao:

Anybody get this fascility to work who can provide a good example?

Share this post


Link to post
Share on other sites



Opt("OnExitFunc","MyOnAutoItExit")

Share this post


Link to post
Share on other sites

I've had the function working just fine. Just add

Func OnAutoItExit()
;code here
EndFunc

and insert your code in the function. OnAutoItExit is the default function, so if it is found, it will be called.

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  
Followers 0