Button_SetCheckState problem |
Author: |
Message: |
WarPenguin
New Member
Posts: 6
Joined: Mar 2008
|
O.P. Button_SetCheckState problem
hi everyone,
Im writing a script that has an options dialog to configure some of its functions. For that purpose im using checkboxes. I wanted the script to read the configurations from a file and set the checkboxes accordingly.
But it gives me this error:
Error: Object doesn't support this property or method (code: -2146827850)
Here is the code:
if(newfile.Readline() == 1){
optionsWnd.Button_SetCheckState("Abreum",true);
}else{
optionsWnd.Button_SetCheckState("Abreum",false);
}
Thanks.
|
|
03-12-2008 05:41 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Button_SetCheckState problem
Which one of those lines is mentioned in the debug window? The Button_SetCheckState() appears ok at first glance
<Eljay> "Problems encountered: shit blew up"
|
|
03-12-2008 05:47 PM |
|
|
WarPenguin
New Member
Posts: 6
Joined: Mar 2008
|
O.P. RE: Button_SetCheckState problem
This one:
optionsWnd.Button_SetCheckState("Abreum",true);
|
|
03-12-2008 05:57 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Button_SetCheckState problem
Can you post the entire js file. It may be that optionsWnd is null or not PlusWnd object.
|
|
03-12-2008 05:58 PM |
|
|
WarPenguin
New Member
Posts: 6
Joined: Mar 2008
|
O.P. RE: Button_SetCheckState problem
Thats what I thought first but I've played around with it, and Im sure thats not the problem.
|
|
03-12-2008 06:00 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Button_SetCheckState problem
quote: Originally posted by WarPenguin
Thats what I thought first but I've played around with it, and Im sure thats not the problem.
Then before the if statement that you posted above put in
Debug.Trace(typeof optionsWnd);
Debug.Trace(optionsWnd.Handle);
Post with the debug results from that.
This post was edited on 03-12-2008 at 06:02 PM by matty.
|
|
03-12-2008 06:01 PM |
|
|
WarPenguin
New Member
Posts: 6
Joined: Mar 2008
|
O.P. RE: Button_SetCheckState problem
This is the result:
string
Error: Object doesn't support this property or method (code: -2146827850)
|
|
03-12-2008 06:05 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Button_SetCheckState problem
Ok so optionsWnd should be an object not a string.
Post your code I will see what you did wrong.
|
|
03-12-2008 06:06 PM |
|
|
WarPenguin
New Member
Posts: 6
Joined: Mar 2008
|
O.P. RE: Button_SetCheckState problem
Here it is:
var AbreUm;
var AbreDois;
var AbreTres;
var SignIn;
var SignOut;
var Sound;
...(This functions have nothing to do with the options)
function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd){
if(MenuItemId == "About"){
MsgPlus.CreateWnd("about.xml", "about");
}
if(MenuItemId == "Options"){
MsgPlus.CreateWnd("options.xml", "options");
ReadSettings("options");
}
}
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);
if(PlusWnd.Button_IsChecked("Abreum") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
if(PlusWnd.Button_IsChecked("Abredois") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
if(PlusWnd.Button_IsChecked("Abretres") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
if(PlusWnd.Button_IsChecked("signIn") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
if(PlusWnd.Button_IsChecked("sound") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
if(PlusWnd.Button_IsChecked("signOut") == true){
newfile.WriteLine("1");
}else{
newfile.WriteLine("0");
}
newfile.Close();
}
function OnOptionsEvent_CtrlClicked(PlusWnd, ControlId){
if(ControlId == "BtnCancel"){
PlusWnd.Close(2);
}
if(ControlId == "OK"){
WriteSettings(PlusWnd);
PlusWnd.Close(1);
}
}
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);
Debug.Trace(typeof optionsWnd);
Debug.Trace(optionsWnd.Handle);
if(newfile.Readline() == 1){
AbreUm = true;
optionsWnd.Button_SetCheckState("Abreum",AbreUm);
}else{
AbreUm = false;
optionsWnd.Button_SetCheckState("Abreum",AbreUm);
}
if(newfile.Readline() == 1){
AbreDois = true;
optionsWnd.Button_SetCheckState("Abredois",AbreDois);
}else{
AbreDois = false;
optionsWnd.Button_SetCheckState("Abredois",AbreDois);
}
if(newfile.Readline() == 1){
AbreTres = true;
optionsWnd.Button_SetCheckState("Abretres",AbreTres);
}else{
AbreTres = false;
optionsWnd.Button_SetCheckState("Abretres",AbreTres);
}
if(newfile.Readline() == 1){
SignIn = true;
optionsWnd.Button_SetCheckState("signIn",SignIn);
}else{
SignIn = false;
optionsWnd.Button_SetCheckState("signIn",SignIn);
}
if(newfile.Readline() == 1){
Sound = true;
optionsWnd.Button_SetCheckState("sound", Sound);
}else{
Sound = false;
optionsWnd.Button_SetCheckState("sound", Sound);
}
if(newfile.Readline() == 1){
SignOut = true;
optionsWnd.Button_SetCheckState("signOut", SignOut);
}else{
SignOut = false;
optionsWnd.Button_SetCheckState("signOut", SignOut);
}
newfile.Close();
}
|
|
03-12-2008 06:10 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Button_SetCheckState problem
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();
}
This post was edited on 03-12-2008 at 06:24 PM by matty.
|
|
03-12-2008 06:15 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|