Sign in to follow this  
Followers 0
laphlaw

Trouble with including user-defined functions

3 posts in this topic

Whenever I try and include a custom-made function (we'll call it myfunction) my function always runs twice. For example.....

#include<myfunction.au3>

myfunction()

The above script would run my function twice. It appears that autoit actually runs the function when I include it, then runs it again when I call it. The script shouldn't run when I just include it... am I missing something here?? Please help!

Share this post


Link to post
Share on other sites



Whenever I try and include a custom-made function (we'll call it myfunction) my function always runs twice.  For example.....

#include<myfunction.au3>

myfunction()

The above script would run my function twice.  It appears that autoit actually runs the function when I include it, then runs it again when I call it.  The script shouldn't run when I just include it... am I missing something here??  Please help!

<{POST_SNAPBACK}>

Yes, the script runs when you include. Yes, this is supposed to happen, because if any of the functions in the included script need certain global variables to be initialized before they work then the included script can initialize them.

If don't want a function to run twice, then either don't call it in the original file, or don't bother calling it in the parent script.

Share this post


Link to post
Share on other sites

i don't know if i'm right (just started autoit) but doesn't it help when you put the #include-once in your include file?

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