What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [SOLVED] Global variable not changing value

[SOLVED] Global variable not changing value
Author: Message:
DELmE
New Member
*


Posts: 3
Joined: May 2010
O.P. [SOLVED] Global variable not changing value
Hey guys, I'm new here and I'm pretty excited about finding this for Windows Live, auto responders and stuff are so cool :)

I'm trying to write a simple log in script so that I will eventually be able to send commands to my computer over Windows Live, but I've hit a small roadblock.

I have a global variable named admin, that will hold the user name of the person who is logged in as the admin and can execute command, this is what I have so far:

code:
var admin = String("");

function OnEvent_Initialize(MessengerStart)
{
}

function OnEvent_Uninitialize(MessengerExit)
{
}

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind)
{
    switch (Message) {
        case ".hello":
            if (MsgPlus.RemoveFormatCodes(Origin) == admin) {
                 ChatWnd.SendMessage("Hello :)");
                 ChatWnd.SendMessage("/close");
             } else {
                 ChatWnd.SendMessage("You are not an admin! Admin:" + admin);
                 ChatWnd.SendMessage("/close");
             }
         case ".login":
             admin = MsgPlus.RemoveFormatCodes(Origin);
             ChatWnd.SendMessage("Password accepted :) admin:" + admin);
             ChatWnd.SendMessage("/close");
         case ".logout":
             admin="";
     }
}


My problem is that when the '.login' command is executed the value 'Origin' gets put into the admin variable fine, but then when the function ends admin no longer contains any data. Any ideas? I am a fluent AutoIt coder and a semi fluent C/C++ coder, but I have never used Js or Java before..

Thanks guys :)

This post was edited on 05-06-2010 at 12:53 PM by DELmE.
05-06-2010 12:20 PM
Profile PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: [HELP] Global variable not changing value
I can't test at the moment, but try replacing
var admin = String("");
with
var admin = "";

and place after each case statement:
js code:
case ".login":
             admin = MsgPlus.RemoveFormatCodes(Origin);
             ChatWnd.SendMessage("Password accepted :) admin:" + admin);
             ChatWnd.SendMessage("/close");
break;

[signature.jpg]
05-06-2010 12:49 PM
Profile E-Mail PM Find Quote Report
DELmE
New Member
*


Posts: 3
Joined: May 2010
O.P. RE: RE: [HELP] Global variable not changing value
quote:
Originally posted by foaly
I can't test at the moment, but try replacing
var admin = String("");
with
var admin = "";

and place after each case statement:
js code:
case ".login":
             admin = MsgPlus.RemoveFormatCodes(Origin);
             ChatWnd.SendMessage("Password accepted :) admin:" + admin);
             ChatWnd.SendMessage("/close");
break;



Ok, thanks for the fast reply :) Ill give it a try
05-06-2010 12:50 PM
Profile PM Find Quote Report
DELmE
New Member
*


Posts: 3
Joined: May 2010
O.P. RE: [HELP] Global variable not changing value
Works like a charm, thanks foaly. Don't know why I didn't try putting breaks in.. Thanks for the help :)
05-06-2010 12:53 PM
Profile PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: [HELP] Global variable not changing value
quote:
Originally posted by DELmE
Works like a charm, thanks foaly. Don't know why I didn't try putting breaks in.. Thanks for the help :)
no probs :)
[signature.jpg]
05-06-2010 12:55 PM
Profile E-Mail PM Find Quote Report
« 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