Shoutbox

Strange Error - 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: Strange Error (/showthread.php?tid=72029)

Strange Error by A06 on 02-22-2007 at 09:56 PM

Hi !
i've a problem with my script...

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
   if (Message.match(/^!massmsg$/))
   {
      MsgPlus.DisplayToast("Mass Message :: Usage","!massmsg <message>");
      return "";
   }
   else if (Message.match(/^!massmsg .+/))
   {
      var strMessage = Message.substr(9);
     Debug.trace(strMessage);
      var Contacts = Messenger.MyContacts;
      var e = new Enumerator(Contacts);
      var Contact = e.item();
      for(; !e.atEnd(); e.moveNext())
      {
         var Contact = e.item();
         if (Contact.Status != 1)
         {
            var ChatWnd2 = Messenger.OpenChat(Contact.Email);
           Debug.trace(strMessage);
            ChatWnd2.SendMessage(strMessage);
         }
      }
       return "";
   }
}

The Error : Erreur : 'null' a la valeur Null ou n'est pas un objet..

~= 'null' egal Null or is not an object.

The line where is signaled the error : ChatWnd2.SendMessage(strMessage);

The both Debug.trace(strMessage) are Ok
RE: Strange Error by RaceProUK on 02-22-2007 at 10:46 PM

First guess:
var ChatWnd2 = Messenger.OpenChat(Contact.Email);
results in ChatWnd2 being null. Try a Debug.Trace on ChatWnd2 after the aforementioned line.


RE: Strange Error by TheGuruSupremacy on 02-22-2007 at 11:16 PM

quote:
Originally posted by A06
Hi !
i've a problem with my script...
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
   if (Message.match(/^!massmsg$/))
   {
      MsgPlus.DisplayToast("Mass Message :: Usage","!massmsg <message>");
      return "";
   }
   else if (Message.match(/^!massmsg .+/))
   {
      var strMessage = Message.substr(9);
     Debug.trace(strMessage);
      var Contacts = Messenger.MyContacts;
      var e = new Enumerator(Contacts);
      var Contact = e.item();
      for(; !e.atEnd(); e.moveNext())
      {
         var Contact = e.item();
         if (Contact.Status != 1)
         {
            var ChatWnd2 = Messenger.OpenChat(Contact.Email);
           Debug.trace(strMessage);
            ChatWnd2.SendMessage(strMessage);
         }
      }
       return "";
   }
}

The Error : Erreur : 'null' a la valeur Null ou n'est pas un objet..

~= 'null' egal Null or is not an object.

The line where is signaled the error : ChatWnd2.SendMessage(strMessage);

The both Debug.trace(strMessage) are Ok



Maybe you have added your Address in your contacts list....(i mean that maybe you have added yourself contact...example:if your email is mmm@hotmail.com..you have added a contact with mmm@hotmail.com address...)if it's so...you must change your code like this because you can't send  yourself a message  :
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
   if (Message.match(/^!massmsg$/))
   {
      MsgPlus.DisplayToast("Mass Message :: Usage","!massmsg <message>");
      return "";
   }
   else if (Message.match(/^!massmsg .+/))
   {
      var strMessage = Message.substr(9);
Debug.trace(strMessage);
      var Contacts = Messenger.MyContacts;
      var e = new Enumerator(Contacts);
      var Contact = e.item();
      for(; !e.atEnd(); e.moveNext())
      {
         var Contact = e.item();{
         if (Contact.Email!=Messenger.MyEmail){
         if (Contact.Status != 1)
         {
            var ChatWnd2 = Messenger.OpenChat(Contact.Email);
       Debug.trace(strMessage);
            ChatWnd2.SendMessage(strMessage);
         }}}
      }
       return "";
   }
}



EDIT:MOREOVER PAY ATTENTION THAT A WLM SERVERS HAVE A LIMITATION YOU CAN'T SEND A MESSAGGE TOO YOUR CONTATCS IN A MINUTE.THE SERVER REFUSES IT