Shoutbox

Help With Scripting Please! - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Help With Scripting Please! (/showthread.php?tid=71299)

Help With Scripting Please! by Malekith on 02-02-2007 at 12:49 AM

I need some help with some scripting, before i explain heres part of my code:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, Type) {
    var Contacts = ChatWnd.Contacts;
    var e = new Enumerator(Contacts);
    var Contact = e.item();

    var command = Message.substr(0,7);
    var strMessage = Message.substr(8);
   
    if (ChatOpen != true) {
        if (command == "!secure") {
            var ContactEmail = Contact.Email;
            var Wnd = MsgPlus.CreateWnd("Interface.xml", "WndMain");
            var ChatWindowID = ChatWnd;
            Wnd.SetControlText("lblChatting",ContactEmail)
            ChatOpen = true;
        }
    }
   
    if (Contact.Email != Messenger.MyEmail) {
        var strCurrentChat = Wnd.GetControlText("txtChat");
        Wnd.SetControlText("txtChat","<" + Contact.Email + "> " + Message + "\r\n");
    }
   
    return Message;
}

What i want to do is make Wnd a constant/global variable so i can always access it because i need to keep using it everytime a message is recieved. So what im asking is if there is a way to make global variables OR if i can iterate through the windows and find the one with the id of WndMain. I really need help with this, thanks.

/-- Malekith
RE: Help With Scripting Please! by roflmao456 on 02-02-2007 at 12:51 AM

just make a global variable, not hard!

put the variable Wnd outsite of the function and its global.


RE: Help With Scripting Please! by Malekith on 02-02-2007 at 12:57 AM

Sorry, i havtn done any coding in a while? so if i do var Wnd; outside the function and then just do Wnd = XXX; inside the function, it should make it global?


RE: Help With Scripting Please! by roflmao456 on 02-02-2007 at 12:59 AM

quote:
Originally posted by Malekith
Sorry, i havtn done any coding in a while? so if i do var Wnd; outside the function and then just do Wnd = XXX; inside the function, it should make it global?
yeah, just move var Wnd thts all then you can treat it as if it were a local one. (except for when you close it)
RE: Help With Scripting Please! by NanaFreak on 02-02-2007 at 01:00 AM

yes thats how you make a global variable also if you do this:

code:
function ... {
//stuff
Wnd = "123";
//stuff
}
that makes a global variable as well ;)
RE: Help With Scripting Please! by Malekith on 02-02-2007 at 01:07 AM

Sorry, for my noobness :(