Your original function
code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId == "About"){
MsgPlus.CreateWnd("about.xml", "about");
}
if(MenuItemId == "Options"){
MsgPlus.CreateWnd("options.xml", "options");
ReadSettings("options");
}
You are passing a string as the window object.
code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId == "About"){
MsgPlus.CreateWnd("about.xml", "about");
}
else if(MenuItemId == "Options"){
var optionsWnd = MsgPlus.CreateWnd("options.xml", "options");
ReadSettings(optionsWnd);
}
}
This code passes the window object.
Alternately you can do this
code:
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId == "About"){
MsgPlus.CreateWnd("about.xml", "about");
}
else if(MenuItemId == "Options"){
ReadSettings(MsgPlus.CreateWnd("options.xml", "options"));
}
}
Also your read settings function can be altered
code:
function ReadSettings(optionsWnd){
Debug.Trace("Reading settings from file...");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var newfile = fso.OpenTextFile(MsgPlus.ScriptFilesPath + "\\Settings.txt",1,true);
optionsWnd.Button_SetCheckState("Abreum", (newfile.Readline() == 1 ? true : false));
optionsWnd.Button_SetCheckState("Abredois",(newfile.Readline() == 1 ? true : false));
optionsWnd.Button_SetCheckState("Abretres",(newfile.Readline() == 1 ? true : false));
optionsWnd.Button_SetCheckState("signIn",(newfile.Readline() == 1 ? true : false));
optionsWnd.Button_SetCheckState("sound", (newfile.Readline() == 1 ? true : false));
optionsWnd.Button_SetCheckState("signOut",(newfile.Readline() == 1 ? true : false));
newfile.Close();
}
code:
function WriteSettings(PlusWnd){
Debug.Trace("Writing settings to file...");
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CreateTextFile(MsgPlus.ScriptFilesPath + "\\Settings.txt",true);
var newfile = fso.OpenTextFile(MsgPlus.ScriptFilesPath + "\\Settings.txt",8,true);
newfile.WriteLine(PlusWnd.Button_IsChecked("Abreum"));
newfile.WriteLine(PlusWnd.Button_IsChecked("Abredois"));
newfile.WriteLine(PlusWnd.Button_IsChecked("Abretres");
newfile.WriteLine(PlusWnd.Button_IsChecked("signIn"));
newfile.WriteLine(PlusWnd.Button_IsChecked("sound"));teLine(PlusWnd.Button_IsChecked("signOut"));
newfile.Close();
}