Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Global, Local variables and memory  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Global, Local variables and memory
« on: December 09, 2008, 05:08:22 PM »

A new be question.
1. I can declare a global variable in base.inc, so it is available through the whole game without having to "declare" it again (right?).
2. I can declare a global variable in an other "local" script, so it is also available to other scripts, if I "declare" it again (right?).
What is the difference from memory side?
As I can understand it, in first case the variable is stored in memory and stays there until I quit the game.
What happens in second case?
And what about in case of Local variables (and memory)?

Best regards,
Spyros

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Global, Local variables and memory
« Reply #1 on: December 09, 2008, 05:19:24 PM »

Once you declare a global variable, it stays in memory forever. Local variables live within their scope (variables declared in functions are destroyed once the function ends, variables declared in scripts are destroyed once the script ends).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Global, Local variables and memory
« Reply #2 on: December 09, 2008, 05:26:38 PM »

Thank you for your quick answer Mnemonic.
Most helpfull.

Spyros
 

Page created in 0.035 seconds with 20 queries.