Shoutbox

HELP - No error, no action... - 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: HELP - No error, no action... (/showthread.php?tid=90414)

HELP - No error, no action... by whiz on 04-28-2009 at 07:50 PM

It flips the status, or at least it did until I did something to it that stops it working.

Javascript code:
var Activity = "Disabled";
 
var Messenger = 14;
var Mode = "All Values";
var Refresh = 1000;  // will add a method of changing this later
 
var OldStatus;
 
MsgPlus.AddTimer("FlipStatus", Refresh);
 
function OnGetScriptMenu (nLocation)
{
    Menu = '<ScriptMenu>';
   
    if (Activity == "Enabled")
    {
        Menu += '<MenuEntry Id=\"Activity\">Disable Flip Status...</MenuEntry>';
    }
    else
    {
        Menu += '<MenuEntry Id=\"Activity\">Enable Flip Status...</MenuEntry>';
    }
   
    Menu += '<Separator/>';
   
    if (Activity == "Enabled" || Mode == "On/Off Only")
    {
        Menu += '<MenuEntry Id=\"Messenger\" Enabled=\"false\">Messenger: ' + Messenger + '</MenuEntry>';
    }
    else
    {
        Menu += '<MenuEntry Id=\"Messenger\">Messenger: ' + Messenger + '</MenuEntry>';
    }
   
    if (Activity == "Enabled")
    {
        Menu += '<MenuEntry Id=\"Mode\" Enabled=\"false\">Mode: ' + Mode + '</MenuEntry>';
        Menu += '<MenuEntry Id=\"Refresh\" Enabled=\"false\">Refresh: ' + Refresh + 'ms</MenuEntry>';
    }
    else
    {
        Menu += '<MenuEntry Id=\"Mode\">Mode: ' + Mode + '</MenuEntry>';
        Menu += '<MenuEntry Id=\"Refresh\">Refresh: ' + Refresh + 'ms</MenuEntry>';
    }
   
    Menu += '</ScriptMenu>';
       
    return Menu;
}
 
function OnEvent_MenuClicked (sMenuId, nLocation, iOriginWnd)
{
    if (sMenuId == "Activity")
    {
        if (Activity == "Enabled")
        {
            Activity = "Disabled";
            Messenger.MyStatus = OldStatus;
        }
        else if (Activity == "Disabled")
        {
            OldStatus = Messenger.MyStatus;
            Activity = "Enabled";
        }
    }
    if (sMenuId == "Messenger")
    {
        if (Messenger == 9)
        {
            Messenger = 14;
        }
        else if (Messenger == 14)
        {
            Messenger = 9;
        }
    }
    if (sMenuId == "Mode")
    {
        if (Mode == "All Values")
        {
            Mode = "On/Off Only";
        }
        else if (Mode == "On/Off Only")
        {
            Mode = "All Values";
        }
    }
}
 
function OnEvent_Timer(TimerId)
{
    if (TimerId == "FlipStatus")
    {
        if (Activity == "Enabled")
        {
            if (Mode == "All Values")
            {
                if (Messenger == 9)
                {
                    switch (Messenger.MyStatus)
                    {
                        case 3:
                            Messenger.MyStatus = 4;
                            break;
                        case 4:
                            Messenger.MyStatus = 5;
                            break;
                        case 5:
                            Messenger.MyStatus = 7;
                            break;
                        case 7:
                            Messenger.MyStatus = 8;
                            break;
                        case 8:
                            Messenger.MyStatus = 9;
                            break;
                        case 9:
                            Messenger.MyStatus = 3;
                            break;
                        default:
                            Messenger.MyStatus = 3;
                            break;
                    }
                }
                else if (Messenger == 14)
                {
                    switch (Messenger.MyStatus)
                    {
                        case 3:
                            Messenger.MyStatus = 4;
                            break;
                        case 4:
                            Messenger.MyStatus = 7;
                            break;
                        case 7:
                            Messenger.MyStatus = 3;
                            break;
                        default:
                            Messenger.MyStatus = 3;
                            break;
                    }
                }
            }
            else if (Mode == "On/Off Only")
            {
                switch (Messenger.MyStatus)
                {
                    case 2:
                        Messenger.MyStatus = 3;
                        break;
                    case 3:
                        Messenger.MyStatus = 2;
                        break;
                    default:
                        Messenger.MyStatus = 3;
                        break;
                }
            }
        }
        MsgPlus.AddTimer("FlipStatus", Refresh);
    }
}


It's probably something really obvious, but I've been looking at it for 20 minutes and I don't see what's up with it.  If it helps, I found out (using the script debugger) that it always reaches the "switch (Messenger.MyStatus)" bit, but it just doesn't match the number with the status, even though it did before.  Can anyone explain what I must have missed?
RE: HELP - No error, no action... by Spunky on 04-29-2009 at 05:55 AM

Not 100% without looking a bit further into it, buttry changing the variable Messenger to Msgr or something similar. I think it might be conflicting with the object Messenger


RE: HELP - No error, no action... by Matti on 04-29-2009 at 10:56 AM

quote:
Originally posted by Spunky
Not 100% without looking a bit further into it, buttry changing the variable Messenger to Msgr or something similar. I think it might be conflicting with the object Messenger
Very correct. To make it even worse, you're trying to use Messenger in the same scope in both meanings (the object and your number variable) - there's absolutely no way the engine will be able to work with that.

Also, I'd recommend you to use a Boolean value for your Activity and Mode variables. It is totally unnecessary to force the JScript engine into comparing two strings when you know it can only have two values. Try to give your Mode variable a better name, or start using number constants for your settings, it'll greatly improve the quality of your code.
RE: HELP - No error, no action... by whiz on 04-29-2009 at 06:14 PM

Hoorah, it works again.  Thanks!  :)