What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] Disable/Enable.

[Request] Disable/Enable.
Author: Message:
Seed
New Member
*


Posts: 3
Joined: Apr 2010
O.P. [Request] Disable/Enable.
Hi people,

I'm french so, i'm really sorry if you don't understand me immediatly. I'll try to do the best i can. :/

So, i need to get a part of script to active/desactive my script with a variable for example. I mean, a menu with the name of my script, and one option : "Disable" and "Enable", When my script is enable, i want a var with 1, and Disable 0. ^^

But i really don't know how to do that, i was trying with some scripts (Like Answering Machine Plus!), but i can't do same. Can you please help me ? ^^

Thanx,
Best regards.

EDIT : And on my JS, i'll need to do a if(Enable == 1), but i don't know how to get the var.. please help. ^.^

EDIT ² : I can make it with "goto", but i don't know how to place "goto". :/

This post was edited on 04-09-2010 at 08:12 PM by Seed.
04-09-2010 07:54 PM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: [Request] Disable/Enable.
js code:
var Enabled = 1;

function OnGetScriptMenu()
{
    var Menu = "<ScriptMenu>";
    Menu += "    <MenuEntry Id=\"ToggleEnable\">" + (Enabled ? "En" : "Dis") + "able...</MenuEntry>";
    return Menu + "</ScriptMenu>";
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    switch (MenuItemId)
    {
        case "ToggleEnable":
            Enabled = !Enabled; // toggle the value
            break;
        // add additional menu items here...
    }
}

That'll make a menu, which, when enabled, will display "Disable...", and when disabled, will display "Enable...".

Also...  using "goto" is for batch files, not JScript.  :)
04-09-2010 08:15 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Request] Disable/Enable.
Add a variable called Enable at the top of any of the JS files?
04-09-2010 08:15 PM
Profile E-Mail PM Find Quote Report
Seed
New Member
*


Posts: 3
Joined: Apr 2010
O.P. RE: [Request] Disable/Enable.
Nice Whiz it's what i want but i got some problem.

Look my code :

code:
var Enabled = 0;

function OnGetScriptMenu()
{
    var Menu = "<ScriptMenu>";
    if(Enabled==0) { Menu += "   <MenuEntry Id=\"ToggleEnable\">Enable</MenuEntry>"; }
    if(Enabled==1) { Menu += "   <MenuEntry Id=\"ToggleEnable\">Disable</MenuEntry>"; }
    return Menu + "</ScriptMenu>";
}

function OnEvent_MenuClicked(MenuItemId, Location, OriginWnd)
{
    switch (MenuItemId)
    {
        case "ToggleEnable":
            if(Enabled == 1) { Enabled = 0; }
            if(Enabled == 0) { Enabled = 1; }
            break;
        // add additional menu items here...
    }
}

And after :

code:
if(Enabled==1)
{
[...]My Code[...]
}
else
{
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if(Message=="!is_activated"){

return "Result is : " + Enabled;
}
}
}

But my code does not work.. (After the if), when i do !is_activated, answer is 1 (Enabled). But after, don't work.

A part of my code :

code:
if(Enabled==1)
{
function SendMessage(sMessage)
{
return sMessage;
}

function OnEvent_ChatWndSendMessage(ChatWnd,Message){

if(Message=="Email"){
return 'blabla';
}

When i type "Email", return is.. "Email". 8-|

Do you know why ?

Thanx,
Best regards !

EDIT : The menu works, it's just my code, i think it's the "if". :/

This post was edited on 04-09-2010 at 08:52 PM by Seed.
04-09-2010 08:51 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Request] Disable/Enable.
I suggest posting all of your code not just snippets. And use the following tags:

[code=js][/code]

04-09-2010 09:45 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [Request] Disable/Enable.
js code:
            if(Enabled == 1) { Enabled = 0; }
            if(Enabled == 0) { Enabled = 1; }

Could just be:
js code:
Enabled = !Enabled;

Also, the ChatWndSendMessage event appears to be in an if statement... No experience with this (I'm guessing though it's not right), but I would say that's why it only works properly in one condition.
<Eljay> "Problems encountered: shit blew up" :zippy:
04-09-2010 11:03 PM
Profile PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: RE: [Request] Disable/Enable.
js code:
            if(Enabled == 1) { Enabled = 0; }
            if(Enabled == 0) { Enabled = 1; }
You need to use an Else (or what Spunky said), otherwise it will always be 1.

This post was edited on 04-09-2010 at 11:18 PM by Volv.
04-09-2010 11:18 PM
Profile PM Find Quote Report
Seed
New Member
*


Posts: 3
Joined: Apr 2010
O.P. RE: [Request] Disable/Enable.
Fixed.

And the code works, i just move the 'if' after the 'function' and it's works fine.

Thanx for all ! :)
04-10-2010 10:54 AM
Profile E-Mail PM 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