Shoutbox

[?] SendMessage Problem - 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: [?] SendMessage Problem (/showthread.php?tid=68897)

[?] SendMessage Problem by Spunky on 11-27-2006 at 02:02 PM

I'm passing the ChatWnd and Message params from the OnEvent_ChatWndSendMessage event to my own custom function. The reason for this is because it uses an xml request and if I just returned the values, it returns to late and the message had already sent. So I'm using the ChatWnd.SendMessage function to send a message to the same window that calledthe function. I'm using:

code:
Debug.Trace(ChatWnd.SendMessage(Message));
which returns true. It doesn't seem to be adding anything to the chat window however.

Any ideas?
RE: [?] SendMessage Problem by Felu on 11-27-2006 at 02:15 PM

Works fine for me [Image: xso_undecided.gif]

code:
function OnEvent_ChatWndSendMessage(Wnd, Msg){
Debug.Trace(Wnd.SendMessage("Bleh"))
}
Traces true and even send the message.
RE: [?] SendMessage Problem by CookieRevised on 11-27-2006 at 04:42 PM

SpunkyLoveMuff,

provide all the code you use in cases like this. Most likely this is a bug in your coding, not in Plus!.

Because:

quote:
Originally posted by SpunkyLoveMuff
I'm passing the ChatWnd and Message params from the OnEvent_ChatWndSendMessage event to my own custom function. The reason for this is because it uses an xml request and if I just returned the values, it returns to late and the message had already sent.
Indicates that you don't have coded this properly since a function will not return automatically on its own before every statement has been executed. Same goes for Plus! events which are nothing more than functions containing statements.

aka: you can simply put your xml request into the event too, it will not make any difference; the event will not return until you return something with code. And thus the actual message will not change or be shown until you return from the event (logically, because otherwise Plus! doesn't have clue what to do, changing the message, discarding the message, showing the message, etc).
RE: [?] SendMessage Problem by Spunky on 11-27-2006 at 04:50 PM

I have managed to fix this now. It's because the ChatWnd.SendMessage function was sending the data back to OnEvent_ChatWndSendMessage and then the code would loop again, but return ""...


RE: [?] SendMessage Problem by CookieRevised on 11-27-2006 at 08:22 PM

quote:
Originally posted by SpunkyLoveMuff
I have managed to fix this now. It's because the ChatWnd.SendMessage function was sending the data back to OnEvent_ChatWndSendMessage and then the code would loop again, but return ""...
I see... though the ChatWnd.SendMessage function doesn't send anything back. It sends data to the chatwindow, probably triggering another OnEvent_ChatWndSendMessage, and that is what looped.

1) OnEvent_ChatWndSendMessage is triggered (A)
2)    you perform somewhere in that function an ChatWnd.SendMessage
3)    Another OnEvent_ChatWndSendMessage is triggered (B)
4)    OnEvent_ChatWndSendMessage (B) is ended and returns
5) OnEvent_ChatWndSendMessage (A) is ended and returns

As you see OnEvent_ChatWndSendMessage (A) isn't finished until all the code/statements which are performed in that function are executed, only then it will finish.

or:

1) OnEvent_ChatWndSendMessage is triggered (A)
2)    you perform somewhere in that function an ChatWnd.SendMessage
3) OnEvent_ChatWndSendMessage (A) is ended and returns
4) Another OnEvent_ChatWndSendMessage is triggered (B)
5) OnEvent_ChatWndSendMessage (B) is ended and returns

Again, no function or event will finish when all statements inside that function are finished.