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]
}