That's why you may want to use OnEvent_Signout() as well
When OnEvent_Signout occurs, you may set Initialised to
false (following my example). When OnEvent_Signin (and therefore OnEvent_Initialize) is called, Initialised will be set to
true, and LoadSettings is called (which then overwrites the previously loaded variables).
You may only declare a variable once (on "the global scope" or "outside functions"), but you can assign it as many values as you want
Inside functions, however, you may use variable names more than once, as long as they're not declared in the same function.
Example:
code:
var myGlobalVar = "Gone global"; // Global scope: accessible throughout the script
function OnEvent_Initialize(bool) {
var myVar = "Hello world"; // local scope: only in this function
myGlobalVar = "WorldWideWeb"; // It's global, accessible everywhere
}
function OnEvent_Uninitialize(bool) {
var myVar = "Goodbye world"; // local scope
Debug.Trace(myGlobalVar); // Again: global scope so accessible throughout script
}
EDIT::
As a security measure, you can let LoadSettings check if Initialised is
true:
code:
function LoadSettings() {
if(Initialised) {
//Load them now
}
}
// an extra security measure could be
function LoadSettings() {
if((Initialised) && (Messenger.MyStatus > 0)) {
//Load them now
}
}