Shoutbox

Syntax 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: Syntax error? (/showthread.php?tid=90085)

Syntax error? by Quantum on 04-09-2009 at 09:32 PM

Well i wanted my messenger to lock when messenger starts. So i wanted to make the script myself and then see if i could do it :P (it's really easy with the doc's after you read it).

So i manged to get to this:

code:
function OnEvent_Initialize(MessengerStart)
{
LockMessenger
true; Lock
);
}

function OnEvent_Uninitialize(MessengerExit)
{
}

But somethings wrong with line 5? I don't seem to notice what it is.

Can anyone help by explaining what's wrong as well has telling me whats wrong. It's a syntax error that was like that in the doc.

Also, can boolean be only true or false?
RE: Syntax error? by matty on 04-09-2009 at 09:59 PM

Yeah because you are using the function all wrong.

LockMessenger is a function of the object MsgPlus.
LockMessenger as 1 parameter that accepts true or false.
true to lock WLM false to unlock it

Javascript code:
function OnEvent_Initialize (bMessengerStart) {
    MsgPlus.LockMessenger (true);
}


And yes a boolean is either true or false nothing else.
RE: Syntax error? by Quantum on 04-09-2009 at 10:01 PM

Oh, i see ;)

Get it now!

Thanks..


RE: Syntax error? by Eljay on 04-09-2009 at 10:02 PM

First, this is how the script should be:

JScript code:
function OnEvent_Initialize(MessengerStart)
{
    MsgPlus.LockMessenger(true);
}


Now for an explanation :P

The way the function is represented in the Syntax section of the documentation isn't really representative of the way you use the code.

quote:
Originally posted by Scripting Docs => MsgPlus::LockMessenger

Syntax
code:
LockMessenger(
    [boolean] Lock
);


This is simply a form of IDL (Interface Definition Language), and is simply to inform developers of the parameters that a method takes and their types.

These functions are actually called in the following format:
code:
NameOfObject.MethodName(param1, param2... paramn);

In this case, the object is MsgPlus, the method name is LockMessenger, and it takes one boolean parameter. Therefore, to lock Messenger it would be called like so: (repeat of above code)
JScript code:
function OnEvent_Initialize(MessengerStart)
{
    MsgPlus.LockMessenger(true);
}


(note: I noticed matty already posted before I submitted this, but it took a while to type so fuck it :P)
RE: Syntax error? by Quantum on 04-09-2009 at 10:06 PM

So whenever i use a function i need to use it with and object? (Like MsgPlus or Messenger)?


RE: Syntax error? by matty on 04-09-2009 at 10:07 PM

Yes


RE: Syntax error? by Eljay on 04-09-2009 at 10:12 PM

quote:
Originally posted by Quantum
So whenever i use a function i need to use it with and object? (Like MsgPlus or Messenger)?

Yes, but some of the objects are global such as Messenger and MsgPlus, whereas some have to be returned by another method such as ChatWnd or Contact.
This is explained along with a list of which objects are/aren't global in the "Objects Reference" page of the Scripting Docs.