Posted: 16th Aug 2011 7:51
I've seen how to declare Global variables. Can I do the same with local or do I need to use a different keyword?
Posted: 16th Aug 2011 9:58
Variables should be local by default, no need to explicitly declare them as such. (However, it seems to be bugged at the minute)
Posted: 16th Aug 2011 14:47
Hi, The local keyword is not used in AppGameKit, and is only implied when you are inside a function. All variables outside of a function are treated as global (whether or not you use the GLOBAL keyword).
Posted: 16th Aug 2011 15:24
So any variable I declare inside my main.agc is automatically Global and if I declare one inside a function it is treated as local?
Posted: 19th Aug 2011 1:58
Yes, you got it.
Posted: 27th Aug 2011 17:34
Lee,
Sorry to say it but this doesn't work. You have to declare it as Global otherwise it crashes the program when you try to make function calls.
Just have to keep that in mind.
Thanks.
Posted: 27th Aug 2011 20:30
Lee - it seems like the auto-assigned ID numbers for resources are NOT global when created.

For instance

mySprite = CreateSprite(myImage)

generates a sprite ID that is not global, and crashes the program when called in a function.
Posted: 27th Aug 2011 21:02
Even if they are global without declare its a good habit of just declaring every variable you use! I know local does not need to be declare and you actully cannot declare them but what i do is i rem them in the functions. rem local temp as integer. Just to have a reminder for myself which variables i'm already using.
Posted: 28th Aug 2011 5:51
The only way I could set and use global variables properly, like a sprite ID is actually use the Global keyword.

When I do not use it, AppGameKit thinks it is two different variables.

Cheers