What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Script Classes

Script Classes
Author: Message:
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. Huh?  Script Classes
I have a problem with classes in my scripts.

code:
class myClass {
   // code here...
}


Apart from that, there's just the OnEvent_Initialize and Uninitialize functions.
I don't know where to put my class code, and whenever it runs it is stopped. I look in the script debugger, and it has syntax error on the line that I have typed class myClass.
What's wrong?
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
07-08-2007 07:52 AM
Profile E-Mail PM Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: Script Classes
it works fine here:

code:
var MyClass = {
   "MyVar" : new String(),
   "MyVar2" : new Boolean(),
   "MyMethod" : function()   {
       MsgPlus.DisplayToast("", "=]");
   }
}

function OnEvent_Initialize(MessengerStart)
{

var a = MyClass;
var b = MyClass;
a.MyVar2 = false;
a.MyVar = " =]  ";

Debug.Trace(a.MyVar);
Debug.Trace(a.MyVar2);

a.MyMethod();
b.MyMethod();

}

:)
07-08-2007 08:39 AM
Profile E-Mail PM Find Quote Report
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. RE: Script Classes
I meant as in Objects. As in classes. So you'd define a class, and then say... var blob = new Car() or something like that.

But anyway, what you've said seems to be the same thing. Thanks :D
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
07-08-2007 10:44 AM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Script Classes
@Toneo

To do it the way you want it you should make it like this:
code:
function myClass(){
this.var1 = ""
this.var2 = ""
this.method = function() {
beep();
}
this.method2 = otherfunc;
}

var myobj = new myClass;

myClass.method()

function otherfunc(){
Messenger.DisplayToast(""", "");
}

You can also find all the info you need right here : MSDN Jscript Reference

This post was edited on 07-08-2007 at 11:20 AM by Ezra.
[Image: 1-0.png]
             
07-08-2007 11:20 AM
Profile PM Web Find Quote Report
Toneo
Junior Member
**

Avatar
Epic.

Posts: 35
Reputation: 2
29 / Male / Flag
Joined: Jul 2007
O.P. RE: Script Classes
Ah, yes, I understand that now. Thanks.
[Image: signature-user=291&back=4&clr=12,102,237&size=80.png]
07-08-2007 11:22 AM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: Script Classes
quote:
Originally posted by felipEx
it works fine here:

code:
var MyClass = {
   "MyVar" : new String(),
   "MyVar2" : new Boolean(),
   "MyMethod" : function()   {
       MsgPlus.DisplayToast("", "=]");
   }
}

function OnEvent_Initialize(MessengerStart)
{

var a = MyClass;
var b = MyClass;
a.MyVar2 = false;
a.MyVar = " =]  ";

Debug.Trace(a.MyVar);
Debug.Trace(a.MyVar2);

a.MyMethod();
b.MyMethod();

}

:)
Correct me if I'm wrong, but isn't that an array rather than a class?  To do classes don't you need to use prototype (which doesn't work on pre-defined classes that Patchou makes accessible)?
[Image: markee.png]
07-08-2007 02:47 PM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: Script Classes
quote:
Originally posted by markee
quote:
Originally posted by felipEx
it works fine here:

code:
var MyClass = {
   "MyVar" : new String(),
   "MyVar2" : new Boolean(),
   "MyMethod" : function()   {
       MsgPlus.DisplayToast("", "=]");
   }
}

function OnEvent_Initialize(MessengerStart)
{

var a = MyClass;
var b = MyClass;
a.MyVar2 = false;
a.MyVar = " =]  ";

Debug.Trace(a.MyVar);
Debug.Trace(a.MyVar2);

a.MyMethod();
b.MyMethod();

}

[Image: msn_happy.gif]
Correct me if I'm wrong, but isn't that an array rather than a class?  To do classes don't you need to use prototype (which doesn't work on pre-defined classes that Patchou makes accessible)?
no its just using the object, the prototype is so that you can share functions, properties over every instance of that object
[Image: dt2.0v2.png]      Happy Birthday, WDZ
07-08-2007 03:00 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