What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » new and need some help

Pages: (3): « First « 1 [ 2 ] 3 » Last »
new and need some help
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: new and need some help
It means that you likely have a syntax error. In the Script preferences window click Enable Debugging or Developer Tools or whatever its called at the bottom.

This will open the Script Debugger and will tell you what is wrong with your script.

Alternatively post both the code and the debug window contents and we can help out.

This post was edited on 12-21-2009 at 01:54 PM by matty.
12-21-2009 01:53 PM
Profile E-Mail PM Find Quote Report
debeste95
New Member
*


Posts: 11
– / Male / Flag
Joined: Dec 2009
O.P. RE: RE: new and need some help
quote:
Originally posted by SmokingCookie
Toepassen = to apply :P

Anyways, in this case, you need to edit the script; either click the Edit button, or open the script file(s ) in your favourite editor. A "damaged" script means there's a serious error. You might want to check the debugging window for more information on this specific error.
thanx, i would try that...
and learned another word today! :D great! :P
12-21-2009 01:55 PM
Profile E-Mail PM Find Quote Report
debeste95
New Member
*


Posts: 11
– / Male / Flag
Joined: Dec 2009
O.P. RE: new and need some help
i got rid of the error, and it worked...
but now a question about actions...
i don't really get where i can find the ections in the help file thingy... are object actions? 'cause i wanna make it so if some1 talks, it automatically says: 'blablablabla' so what's the actin codes for automatically saying something? and where can i find the actions?

sorry, next time i will search first...
i got it...
but what's the difference now between functions and properties?
i know what functions are nog, but what are those properties?

and eh... i made a little code, but it doesn't work... how do you use sendmessage?
code:
var naam

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {
    if(Origin !== Messenger.MyName) { // Check if we did not send the message
        SendMessage(Blablablabla);
         naam=name;
         SendMessage("hallo, " + naam + "!");
         
       // [whatever you want to do]
    }
    return Message; // We don't want to do anything with the Message
}
why doesn't he sends a message?

i added ChatWnd. before both sendmessages, he says blablablabla now, but he doesn't say: hallo (name) !

rofl, 5th edit...
now i also added ChatWnd. before name and it worked, but now he says
halle, undefined!

This post was edited on 12-21-2009 at 04:44 PM by debeste95.
12-21-2009 04:09 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: new and need some help
Because the variable "name" does not exist. I think you mean

JScript code:
naam = Origin;


This'll do.
The sending part: "SendMessage" is not a global function like you are using it. It is a method: a function that belongs to some object. So instead, you need to use this:

JScript code:
var naam;
 
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {
    if(Origin !== Messenger.MyName) { // Check if we did not send the message
        //SendMessage(Blablablabla);
         naam = Origin;
         ChatWnd.SendMessage("hallo, " + naam + "!");
    }
    return Message; // We don't want to do anything with the Message
}


Notice any coincidence like OnEvent_ChatWndReceiveMessage's first parameter and the name of the object that has the SendMessage(); method? These must be the same. The function OnEvent_ChatWndReceiveMessage(); takes four "things" called arguments. The first one is an object: the chat window. The second (Origin) is the screen name of the person that sent the message. Message is the fourth, containing the actual message and the last one, MessageKind, tells you what type of message you're dealing with (offline message, search, search result, normal message etc.; see scripting documentation). Note that you can do this as well:

JScript code:
function OnEvent_ChatWndReceiveMessage(a1,a2,a3,a4) /* function header */{
    [some code in the function body]
}


Plus! won't mind that the argument names have been changed. But once you change the argument names in the function header (see above), you need to change it in the function body as well, so:


JScript code:
function OnEvent_ChatWndReceiveMessage(a1 /* originally the ChatWnd argument */,a2 /* Idem, Origin */,a3 /* Idem Message */,a4 /* Idem MessageKind */) /* function header */{
    a1.SendMessage("Hello world!"); // works okay
    ChatWnd.SendMessage("Hello world!"); // An error will occur now, saying that ChatWnd is not defined
}


So if you wish to stick to "naam = name" thingy:

JScript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,name,Message,MessageKind) {
    [code here]
}


This post was edited on 12-21-2009 at 05:52 PM by SmokingCookie.
12-21-2009 05:49 PM
Profile PM Find Quote Report
debeste95
New Member
*


Posts: 11
– / Male / Flag
Joined: Dec 2009
O.P. RE: RE: new and need some help
quote:
Originally posted by SmokingCookie
Because the variable "name" does not exist. I think you mean

JScript code:
naam = Origin;


This'll do.
The sending part: "SendMessage" is not a global function like you are using it. It is a method: a function that belongs to some object. So instead, you need to use this:

JScript code:
var naam;
 
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {
    if(Origin !== Messenger.MyName) { // Check if we did not send the message
        //SendMessage(Blablablabla);
         naam = Origin;
         ChatWnd.SendMessage("hallo, " + naam + "!");
    }
    return Message; // We don't want to do anything with the Message
}


Notice any coincidence like OnEvent_ChatWndReceiveMessage's first parameter and the name of the object that has the SendMessage(); method? These must be the same. The function OnEvent_ChatWndReceiveMessage(); takes four "things" called arguments. The first one is an object: the chat window. The second (Origin) is the screen name of the person that sent the message. Message is the fourth, containing the actual message and the last one, MessageKind, tells you what type of message you're dealing with (offline message, search, search result, normal message etc.; see scripting documentation). Note that you can do this as well:

JScript code:
function OnEvent_ChatWndReceiveMessage(a1,a2,a3,a4) /* function header */{
    [some code in the function body]
}


Plus! won't mind that the argument names have been changed. But once you change the argument names in the function header (see above), you need to change it in the function body as well, so:


JScript code:
function OnEvent_ChatWndReceiveMessage(a1 /* originally the ChatWnd argument */,a2 /* Idem, Origin */,a3 /* Idem Message */,a4 /* Idem MessageKind */) /* function header */{
    a1.SendMessage("Hello world!"); // works okay
    ChatWnd.SendMessage("Hello world!"); // An error will occur now, saying that ChatWnd is not defined
}


So if you wish to stick to "naam = name" thingy:

JScript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,name,Message,MessageKind) {
    [code here]
}


i want naam to be the name of the person i send to...
i read the helpfile and it says name; returns the other's name...
12-21-2009 05:55 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: new and need some help
That sounds like a Contact object. No Contact object is passed to the OnEvent_ChatWndReceiveMessage(); function. Name is a property of a Contact object. Like a method, a property belongs to a certain object. I'll set an example:

JScript code:
var oContact = Messenger.MyContacts.GetContact("john-doe@live.com"); // Change this Windows Live ID to someone from your contact list!!
 
MsgPlus.DisplayToast("","John-doe@live.com's Windows Live ID: " + oContact.Name);


Oh and on a side note: JScript is case-sensitive. So Name is not the same as name.
12-21-2009 06:02 PM
Profile PM Find Quote Report
debeste95
New Member
*


Posts: 11
– / Male / Flag
Joined: Dec 2009
O.P. RE: new and need some help
buut... that's a piece of code to return the email of someone in my list. but how do i get the e-mail og the one i'm talking with?
12-22-2009 09:40 AM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: new and need some help
You can't do that directly, as there is no "Email" parameter in OnEvent_ChatWndReceiveMessage(); This is where loops come in:

JScript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {
    if(Origin !== Messenger.MyName) {
        for(var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()) {
            Debug.Trace(e.item().Email); // Displays the WlID of the current contact
        }
    }
}


This is a for loop. It works like this:
for(Initial variable(s); Testing condition; Increment) {
    Code
}

  • Initial variable(s): this is what you have at the beginning, so an enumerator, array or whatsoever
  • Testing condition: if, and only if the testing condition is true, the Code will be executed
  • Increment: after the code has been executed, the Increment part is executed. If the Testing condition is false, this will not e executed

This post was edited on 12-22-2009 at 09:52 AM by SmokingCookie.
12-22-2009 09:52 AM
Profile PM Find Quote Report
debeste95
New Member
*


Posts: 11
– / Male / Flag
Joined: Dec 2009
O.P. RE: new and need some help
aah, i think i got it! ;)
thanx, man! you really helped me alot- and fast! :)
12-22-2009 09:55 AM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
29 / Male / Flag
Joined: Jul 2007
RE: new and need some help
You're always welcome, that's what the forums are for ;)
12-22-2009 09:58 AM
Profile PM Find Quote Report
Pages: (3): « First « 1 [ 2 ] 3 » 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