Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Global Variables

Author
Message
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
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

Paulo
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
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

Paulo

Login to post a reply

Server time is: 2024-04-20 10:09:45
Your offset time is: 2024-04-20 10:09:45