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:
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
Well I see what you're up to :P

Why do you call ShowSettings if an error occurs in LoadSettings? Just set X360Gamer (and the other 2) to an empty string (var myVar = "") and create the "Settings" window..

Also, a little note: you my use "(!MessengerStart) && (Messenger.MyStatus > 0)" instead of "MessengerStatus == false (etc)"..

And if you start Messenger, thes script will never be started, unless you hit [CTRL] + [S] in Plus!'s (ot your) editor. You may want to call OnEvent_Initialize with parameter false when OnEvent_SigninReady occurs. It may be handy to declare a variable on the global scope with value false to indicate the script has not yet initialised. Look:

code:
var Initialised = false;

function OnEvent_Initialize(boolMsgStart) {
      if((!boolMsgStart) && (Messenger.MyStatus > 0)) {
            // Whatever you want to do
            Initialised = true;
      }
}

function OnEvent_SigninReady(strEmail) {
      if(!Initialised) { // equal to if(Initilaised == false)
            OnEvent_Initialize(false);
            // Whatever you want to do
      }
}


This post was edited on 11-01-2008 at 06:06 PM by SmokingCookie.
11-01-2008 06:01 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 knew not to trust you, seeing through what I'm doing ;).  Ah well, I've made no secret of it, just trying to do something I like, and learn a littl ein the process.

TBH, the showsettings was being used because thats how I did it in my last script, which worked fine, and to ensure that the strings were always there since it doesn't work without.

Cheers for the !MessengerStart suggestion.  I'm still learning little tricks like that.  hopefully one day I will return to form and be able to script anything again.  (Believe it or not - I struggle to - I was once top of class at Uni, far above everyone else.  Now, I'm on the streets, being handed scraps by those with plenty).


- Sorry, should have explained the script bit there.  When I put up the code, I omitted the UserSignon, which called LoadSettings as well, so that the script did also get the vars when someone signed on, so as to give multi user support.

This post was edited on 11-01-2008 at 06:13 PM by ArkaneArkade.
[Image: adsig.jpg]
11-01-2008 06:10 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
quote:
Originally posted by Leroux
I knew not to trust you, seeing through what I'm doing ;).
quote:

Yea, you use meaningful variable names :P

About the !MessengerStart thingy..
The exclamation sign is the "NOT" operator. So if you have MyVar = false; then !MyVar will be true. You can basically think of the NOT operator "inveting" a boolean.
Also, code controlled by "if(true)" will always be executed (I know it sounds self-explaining :P ). if(!false) will also be executed. (false will be invertedby the "!").
11-01-2008 06:17 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

code:
var Initialised = false;

function OnEvent_Initialize(boolMsgStart) {
      if((!boolMsgStart) && (Messenger.MyStatus > 0)) {
            // Whatever you want to do
            Initialised = true;
      }
}

function OnEvent_SigninReady(strEmail) {
      if(!Initialised) { // equal to if(Initilaised == false)
            OnEvent_Initialize(false);
            // Whatever you want to do
      }
}



I don't mean to criticise, but won't that script only work once, either at startup or when someone signs in, meaning that any subsequent signons (brother for instance) will still have the same variables, or is there some sneaky bit I'm missing?

As for meaningful variables - I have ocd, and can't do otherwise.  Besides, much of my scripting is learned by looking at others scripts, and I'd love someday if that was what mines were used (along with my creation purpose) for and it actually helped people pickup some things.
[Image: adsig.jpg]
11-01-2008 06:31 PM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Saving Settings
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
     }
}



This post was edited on 11-01-2008 at 06:45 PM by SmokingCookie.
11-01-2008 06:36 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
That's why you may want to use OnEvent_Signout() as well ;)
[/code]
I guess you could do it that way.  Just making sure you never had aces up your sleeve.  Unfortunately I got work just now, but I'll give it a try when I get back.  Cheers mate.
[Image: adsig.jpg]
11-01-2008 06:45 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