Sign in to follow this  
Followers 0
Guest BlackDiablo110

Declaring Functions...

3 posts in this topic

I noticed that in AutoIt, all the examples look something like this

NewFunc()

Func NewFunc()

MsgBox(0, "I am new func().", "Hear me roar.")

EndFunc

And usually when you run this script file it will print out the message box.

BUT: What I want to know is, can you declare a function, like the above, but then not use it until later or whatever? Maybe not even at all. Like in java you can make a function, but when you execute the script it won't technically use it unless you have something like:

NewFunc()

After it has been declared. I was just curious, because then you could run a function more than once or in combination with other functions without copy + pasting the entire thing.

Share this post


Link to post
Share on other sites



That's the whole point of functions...

Declare as many functions as you want, then call them as you need them, so for you example:

$result = MsgBox(1, "Testing", "Press OK to run NewFunc, Cancel to exit")
if $result = 1 then
   NewFunc()
else
Exit
endif

Func NewFunc()

MsgBox(0, "I am new func().", "Hear me roar.")

EndFunc

Hope this is what you are looking for


CheersNobby

Share this post


Link to post
Share on other sites

Ahh, ok thanks. For some reason, I already knew that, I guess it just didn't come to my mind. I don't know lol. But thanks anyways!

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