Sign in to follow this  
Followers 0
FreeSiker

Question on function OnAutoItStart()

4 posts in this topic

Hello,

This function don't work because, it run before the variables are declared.

Is it possible to make it work

$test = "hello"

Func OnAutoItStart()
MsgBox (0, "test", $test)
EndFunc

Thank you

Share this post


Link to post
Share on other sites



You will have to define all needed vars in the Func itself:

Func OnAutoItStart()
    Global $test = "hello"
    MsgBox(0, "test", $test)
EndFunc  ;==>OnAutoItStart

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You will have to define all needed vars in the Func itself:

Func OnAutoItStart()
    Global $test = "hello"
    MsgBox(0, "test", $test)
EndFunc ;==>OnAutoItStart
I know but the variable is not realy usable by the rest of the script

Func OnAutoItStart()
    Global $test = "hello"
    MsgBox(0, "test", $test)
EndFunc  ;==>OnAutoItStart

Func OnAutoItExit()
    MsgBox(0, "test", $test)
EndFunc   ;==>OnAutoItExit

Result:

C:\help post.au3(7,28) : WARNING: $test: possibly used before declaration. MsgBox(0, "test", $test)

C:\help post.au3(2,27) : WARNING: $test: declared global in function only. Prefer top of file. Global $test = "hello"

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