Sign in to follow this  
Followers 0
Guest Toba

Global variables and included scripts

3 posts in this topic

Hi,

just have a small question concerning global variables in external scripts. Given two scripts, env.au3 and functions.au3, I'd like to define some global variables in the first one, env.au3, which I want to access in the functions.au3. Therefor I include the env.au3 in functions.au3 with #include "env.au3". Seems it doesn't work, AutoIt complains in 2nd script about variables, which have not been declared first.

Any ideas?

Thx in advance

Thomas

Share this post


Link to post
Share on other sites



I can get 2 scripts communicating?

Example:

1.au3

Global $jim, $mary
$jim="Script 1 Variable"
MsgBox(0, "Title", "Scripr 1  Test 1 jim = " & $jim)
#include "2.AU3"
foo()

Func foo()
MsgBox(0, "Title", "Script 1  Test 2 mary = " & $mary)
EndFunc

2.au3

$mary="Script 2 variable"
MsgBox(0, "Title", "Script 2 Test 1 jim = " & $jim)
foo2()

Func foo2()
MsgBox(0, "Title", "Script 2 Test 2 mary = " & $mary)
EndFunc

Or can move $mary or/& $mary = ... to other script and still works?

Share this post


Link to post
Share on other sites

Thx for your quick reply. Seems your example works, so I guess I got something other wrong in my script.

I can get 2 scripts communicating?

Example:

1.au3

Global $jim, $mary
$jim="Script 1 Variable"
MsgBox(0, "Title", "Scripr 1  Test 1 jim = " & $jim)
#include "2.AU3"
foo()

Func foo()
MsgBox(0, "Title", "Script 1  Test 2 mary = " & $mary)
EndFunc

2.au3

$mary="Script 2 variable"
MsgBox(0, "Title", "Script 2 Test 1 jim = " & $jim)
foo2()

Func foo2()
MsgBox(0, "Title", "Script 2 Test 2 mary = " & $mary)
EndFunc

Or can move $mary or/& $mary = ... to other script and still works?

<{POST_SNAPBACK}>

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