Posted: 21st Aug 2011 23:21
I thought all variables declared in the main.agc, and outside a function would be considered global, but I don't think this works that way.

As far I could understand, when I declare a variable in the main.agc and then try to use it inside a function *in another module*, that variable is not the same of the one declared on main.agc.

For example:

main.agc
--------

x_global = 100

update.agc
----------
Function MyFunc()
print(x_global)
EndFunction


I didn't find any explanation for that issue, so I hope people here could clarify that.

Any ideas?

Thanks
Posted: 21st Aug 2011 23:28
Ha, after hitting the Post button, I found the solution!

So, declaring a variable using the Global keyword in the main.agc, that variable were global all around my project, including functions.

However, on contrary another post here stated, declaring the variable without the Global in the main.agc doesn't make that variable global for all modules in my project.

So, to declare a global variable, I believe we have to:

- Declare it using the Global keyword
- Declare it in the main.agc

Other than that, the variable is not global to the project.

Cheers