Jump to content

Trouble with including user-defined functions


Recommended Posts

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!

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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