What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Code snippet crashing messenger

Code snippet crashing messenger
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. Huh?  Code snippet crashing messenger
whenever the following code I have here is executed, and the HTTP response is not '0', messenger will crash. The first dialog box will open, I click OK, and messenger 'encounters a problem and needs to close'. And, it is sorry for any inconvenience.

So, after "Interop.Call("User32", "MessageBoxW", 0, "1There was a problem..." is executed and closed, messenger crashes. Whats going on here?!

code:
if (ControlId == 'BtnDelete' && activeiid==null){
    var response = Interop.Call("User32", "MessageBoxW", 0, "Are you SURE you want to delete this image?\nOnce deleted, it cannot be recovered.", 'YASS', 1);
    if (response == 1){
        var i = 0;
        while(!(Wnd.LstView_GetSelectedState('LVimagelst', i)))
            i++;
        var sBoundary = randomString(10);
        var mpform = new multipartform(sBoundary);
        mpform.addfield('req', 'imgdelete');
        mpform.addfield('iid', i);
        mpform.addfield(yass.fields.MSNid, Messenger.MyUserId);
        mpform.addfield(yass.fields.Password, yass.config.Pass);
        var sPost = mpform.buildmessage();
        var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("POST", yass.config.URL, false);
        xmlhttp.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + sBoundary);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4) {
                wnd.close(0);
                if(xmlhttp.status == 200) {
                    if (xmlhttp.responseText != 0){
                        Interop.Call("User32", "MessageBoxW", 0, "1There was a problem when trying to complete your request. Please try again later. \nIf this continues, please contact your YASS admin for assistance.", 'YASS', 0);
                    }else{
                        wnd.close(0);
                        OnEvent_MenuClicked('image', 'foo', 'bar')
                    }
                }else{
                    Interop.Call("User32", "MessageBoxW", 0, "2There was a problem when trying to complete your request. Please try again later. \nIf this continues, please contact your YASS admin for assistance.", 'YASS', 0);
                }
            }
        }
        xmlhttp.send(sPost);
    }
}

EDIT: well, commenting the line in question so that is does not execute, stops messenger from crashing, so it has something to do with running the dialog box...

This post was edited on 11-22-2007 at 04:00 PM by MeEtc.
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
11-22-2007 03:50 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Code snippet crashing messenger
Why are you combining " " and ' ' in the call to MessageBox?

I don't see anything wrong elsewhere.
Edit: I think "xmlhttp.send(sPost);" is crashing your script.

This post was edited on 11-22-2007 at 04:13 PM by vikke.
11-22-2007 04:06 PM
Profile E-Mail PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: Code snippet crashing messenger
" " and ' ' are both present because it was a copy/paste job. I usually use single quotes. xmlhttp.send(sPost); can't be crashing it, because that is actually executed before the dialog box. and commenting the line with the dialog box stops messenger from crashing
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
11-22-2007 04:19 PM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Code snippet crashing messenger
code:
xmlhttp.open("POST", yass.config.URL, false);
The "false" indicates that you want it to execute synchronously, so that the script will hang while it's executing the MessageBox in the onreadystatechange function. However, this is not needed because when you let it do it asynchronously, the script will continue and thus will stop it from hanging (I suppose).

I suggest you to try and set it to "true" and see if that makes any difference.

This post was edited on 11-22-2007 at 05:37 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-22-2007 05:35 PM
Profile E-Mail PM Web Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: Code snippet crashing messenger
that fixed it, thanks!
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
11-22-2007 05:54 PM
Profile PM Web Find Quote Report
« 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