What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Saving Settings

Pages: (2): « First [ 1 ] 2 » Last »
Saving Settings
Author: Message:
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. Saving Settings
Hey guys,
I'm looking for a little help, regarding the best way to save persistent settings in a script.  I've been messing around with various different methods all day, and have been having no luck with them.
I started off using the registry, but that just turned buggy once I implemented multiple users.  After that I've tried ini files, and xml files, with little success.
Ideally I'd like to use something neat and tidy, such as xml, but going over things earlier I reallly didn't understand what I was doing, and don't wanna use code like that.  I've been reading the msn pages and stuff, but didn't help much, and I don't want the code if I don't understand it fully, cos I'd really rather learn it a bit better.

so basically, does anyone have any recommendations on good working methods of saving settings.  All I want atm is 2 strings and a bool for 2 seperate users, but I'm hoping to use many more later, once I've ironed out the problems.
Cheers guys,
Leroux
[Image: adsig.jpg]
11-01-2008 02:38 AM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: Saving Settings
If you only want a few settings like that then I think registry is the best way to go.  Take a look at this page to see how to use the email of the user in the path to be able to differentiate them.  I personally prefer to use the UserId rather than Email address as it adds a little security to the settings imo.
[Image: markee.png]
11-01-2008 04:00 AM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: Saving Settings
I did have the registry working, pretty much identical to that, and it's been fine for long enough, but I tried using the email address and after that it started failing to read the registry about a quarter of the time.  The variables I tried setting ended up just blank.
I'll try it with the userid to see if that makes any difference to it.  Perhaps its just my email address screwing it up.
[Image: adsig.jpg]
11-01-2008 04:29 AM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: Saving Settings
You need to make sure that the settings are there to be able to be read and that you are signed in when trying to read them or else it will fail.
[Image: markee.png]
11-01-2008 04:58 AM
Profile PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
Suggestion

[code]
function RegRead(Key) {
      if(Messenger.MyStatus>  0) { // See if someone is signed in
            try { // try reading from Key
                  return new ActiveXObject("WScript.Shell").RegRead(Key);
            }
            catch(e) { // error: it's very likely the key does not exist;
                  return "__none"; // common string telling your script the key doesn't exist
            }
      }
      return "__notsignedin"; // tells the script that no one is signed in
}

This post was edited on 11-01-2008 at 02:27 PM by SmokingCookie.
11-01-2008 02:27 PM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: Saving Settings
Cheers guys, but I did already have it done through a try/catch function that was called at initialise if MyStatus > 1, and also on user signin, just in case noone was in at signon.
Like I said, the the regread was failing about 1 in every 4 atempts, but it was always the same key that I was trying to get, so it definitly existed.

The problem seems to have stopped for the moment now that I'm using the userid instead of email so perhaps it was just that for whatever reason.
[Image: adsig.jpg]
11-01-2008 05:33 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
Hmm.. What OS are you using? I always use email (don't know why :P ) and it works perfectly..
11-01-2008 05:38 PM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: Saving Settings
I'm on XP SP3.  If it works perfectly for you it may be something stupid, my computer screwing up or something (god I hope not, I've already lost one this month).
[Image: adsig.jpg]
11-01-2008 05:43 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
Hmm.. Perhaps you can post some beta version of your script, or an example of your code?

and remove it after 30 minutes
11-01-2008 05:49 PM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: RE: Saving Settings
quote:
Originally posted by SmokingCookie
Hmm.. Perhaps you can post some beta version of your script, or an example of your code?

and remove it after 30 minutes

Lol.  Well, here's the code.  I severely doubt the script will be used by many, and none of this it major enough to steal since it could all be figured out really easily.

code:
function OnEvent_Initialize(MessengerStart)
{
    if ((MessengerStart == false) && (Messenger.MyStatus > 1))
    { LoadSettings(); }
}

function LoadSettings()
{
    try
    {
    X360Gamer = Shell.RegRead(MsgPlus.ScriptRegPath + "\\" + Messenger.MyUserId + "\\X360Gamer");
    X360GamerTag = Shell.RegRead(MsgPlus.ScriptRegPath + "\\" + Messenger.MyUserId + "\\X360GamerTag");
    X360PSM = Shell.RegRead(MsgPlus.ScriptRegPath + "\\" + Messenger.MyUserId + "\\X360PSM");
    }
    catch(exception)
    {
        ShowSettings();
    }
}

function ShowSettings()
{
    X360Settings = MsgPlus.CreateWnd("Interface.xml", "Settings");
    X360Settings.SetControlText("EdtGamerAccount", X360Gamer);
    X360Settings.SetControlText("EdtGamerTag", X360GamerTag);
    if(X360PSM == "Gamenames") { X360Settings.Button_SetCheckState("RadGamenames", true) }
    else if(X360PSM == "Gimmicks") { X360Settings.Button_SetCheckState("RadGimmicks", true) }   
}


- I stand corrected.  I've just saved again after copying that data (no change detected) and the catch went.  Ignored, save again, it got the data.  Just wierd.

This post was edited on 11-01-2008 at 06:02 PM by ArkaneArkade.
[Image: adsig.jpg]
11-01-2008 05:55 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On