Jump to content

Explain #include


Recommended Posts

Hi,

QUESTION 1

So I have 2 files... One with the GUI... Other one with the functions.

What includes I need to add so that I could see all the functions and variables (which are determined as global) that are available in the other file (one to another)

QUESTION 2

Also if I have a dialog file which is

$Run = true

While 1
Sleep(100)
WEnd

Func OnButton1Event() 
Do()
EndFunc

Func OnButton2Event()
$Run = false
EndFunc

and also i have a function in the other file which is

Func Do()
While $Run
WEnd
EndFunc

Will the dialog be responsive while im in the Do() functions loop in the other file? So I could stop the loop in the other file by clicking a button of a dialog.

Edited by Jammer
Link to comment
Share on other sites

To answer your first question:

If you have 2 script files. The first one we will call 1.au3 and the second one we will call 2.au3.

2.au3 looks like this:

Global $TestVar = "Test"

To access the $TestVar variable in 2.au3 from 1.au3 it would look like this:

#include <2.au3>

MsgBox(0,0,$TestVar)

To answer question two:

What you are referring to would be considered "multi-threading" which AutoIT does not support. So no, your dialog would not be responsive.

As for question 3 could you post the code where you call _ArrayDisplay?

Edited by DarkMatter

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Link to comment
Share on other sites

Also if I want to access a variable i 1.au3 from 2.au3?

1.au3:

#include <2.au3>

Global $var = "Hey"

DisplayVarFromScript1()

2.au3:

Func DisplayVarFromScript1()
    MsgBox(0,0,$var)
EndFunc

The easiest way to explain this I guess would be to say that as long as you have "2.au3" included in script "1.au3" they technically can access the same variables as long as the variables in question are made public.

Edited by DarkMatter

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

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...