Local and global interpreters

When you launch or debug a script, by default it is executed by a local interpreter. This is a Lua interpreter instance created exclusively for particular script run. If you set a global variable value in your script, this change will not be visible during the next execution of same script. This is because a new local interpreter will be created.

VSScript also provides single global interpreter instance, which is helpful in cases when you want to store some information between script runs. There is only one global interpreter and it remembers all variable changes made by various script invocations. The disadvantage is that you can't debug code in global interpreter. You have to debug your script in a local interpreter first, then you can easily configure it to be run in the global interpreter.

In order to make your script being run in the global interpreter, put the following line at the beginning of the code:

-- pragma:global

The script will be executed in the global interpreter when run directly from Script Editor window or bound to a custom command. However, it will be still executed in a local interpreter when debugged.

Global interpreter is mainly intended for event handling purpose. Please consult this section for events description.

Table of Contents


Copyright (C) 2012-2015 Soft-Erg. All rights reserved.