What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » How to open group chat windows

Pages: (4): « First « 1 2 [ 3 ] 4 » Last »
How to open group chat windows
Author: Message:
Plan-1130
Full Member
***

I keep askin' myself: why?

Posts: 142
73 / Male / –
Joined: Feb 2005
RE: How to open group chat windows
Global variables are globaly defined, which means you don't have to redefine them again, in no function.
Once defined they are accessable everywhere in all the code.

Local variables, have to be redefined in every function and will be deleted from the memory once the function has ended.

This example will explain:
code:
var GlobalVariable;

function Blah(ParsedVariable1)
{
  var LocalVariable = "value";
  GlobalVariable = "value too";
  Blah2(ParsedVariable1);
}

function Blah2(ParsedVariable2)
{
  //GlobalVariable is still "value too",
  //LocalVariable isn't accessible (but exists in the memory, since Blah isn't yet ended, which will end as soo as Blah2 end, because i called Blah2 inside Blah, as Blah will then wait for Blah2 to end)
  //ParsedVariable2 is the same as ParsedVariable1
  //ParsedVariable isn't accessible (see LocalVariable)
}

Hope this helps :)
My Scripts: UltimatFlooder, Advanced PSM Chat, PlusPrivacy, PlusRemote

[Image: Plan-1130.png]
11-04-2006 06:52 PM
Profile E-Mail PM Find Quote Report
Poki
Junior Member
**


Posts: 16
Joined: Nov 2006
O.P. RE: How to open group chat windows
Yeah, but there is still something that I do not understand.
Do I have to make it explicit that they are global variables? I mean, in Matlab i define, global MyVar...
But, here it seems that it's just defining it outside every function. Is it like that or something else? Because, in that case, I got a problem because my script wasn't taking global variables correctly..I had to redefine them in every function to make it work, even though I defined them outside...so I don't find the problem...
11-04-2006 07:19 PM
Profile E-Mail PM Find Quote Report
Plan-1130
Full Member
***

I keep askin' myself: why?

Posts: 142
73 / Male / –
Joined: Feb 2005
RE: How to open group chat windows
Global variables have to be defined before anything else, like shown in my example, you can't define global variables any other way AFAIK.
My Scripts: UltimatFlooder, Advanced PSM Chat, PlusPrivacy, PlusRemote

[Image: Plan-1130.png]
11-04-2006 07:40 PM
Profile E-Mail PM Find Quote Report
Poki
Junior Member
**


Posts: 16
Joined: Nov 2006
O.P. RE: How to open group chat windows
Well, let me show you what my problem was, may be you figure it out.

I had....
var sEmails = new

Array("mail1@hotmail.com","mail2@hotmail.com","mail3@hotmail.com");

var ContactoUno = Messenger.MyContacts.GetContact(sEmails[0]);
var ContactoDos = Messenger.MyContacts.GetContact(sEmails[1]);
var ContactoTres = Messenger.MyContacts.GetContact(sEmails[2]);

before any function, when I realised I needed global variables in order to be accessed by any function, but the fact was that I had to redefine ContactoUno, ContactoDos, ContactoTres y every function I wanted to use it because I'd get an error if I didn't...
So, they are global but need to be defined in every function? in that case the script worked indeed... or what else could be wrong?
11-05-2006 06:42 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: How to open group chat windows
quote:
Originally posted by Plan-1130
Global variables have to be defined before anything else, like shown in my example, you can't define global variables any other way AFAIK.
Global variables can be defined anywhere in the code as long as they are outside any function and before the code where you use them. Though usually not good practice, the next code is perfectly valid:

[code]function Hello() {
    Debug.Trace(myglobalvariable);
}

var myglobalvariable = 'Hello';

function World() {
    Debug.Trace('World');
}

Hello();
World();


quote:
Originally posted by Poki
Well, let me show you what my problem was, may be you figure it out.

I had....
var sEmails = new Array("mail1@hotmail.com","mail2@hotmail.com","mail3@hotmail.com");

var ContactoUno = Messenger.MyContacts.GetContact(sEmails[0]);
var ContactoDos = Messenger.MyContacts.GetContact(sEmails[1]);
var ContactoTres = Messenger.MyContacts.GetContact(sEmails[2]);

before any function, when I realised I needed global variables in order to be accessed by any function, but the fact was that I had to redefine ContactoUno, ContactoDos, ContactoTres y every function I wanted to use it because I'd get an error if I didn't...
So, they are global but need to be defined in every function? in that case the script worked indeed... or what else could be wrong?


All the variables you defined there are global already.

Your problem is that you don't have valid values defined to them when the script starts.

Scripts are started before objects like Messenger are fully available. Thus when the script engine comes to ContactoUno it tries to parse/execute those methods from the Messenger object but they aren't available yet, hence the error.

That's exactly why you need to use events like OnEvent_Initialize(bMessengerStart), or in the above case even better OnEvent_SigninReady(sEmail).



Study the Official Plus! Live Scripting Documentation and the JScript 5.6 Documentation.


This post was edited on 11-05-2006 at 11:11 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-05-2006 10:58 PM
Profile PM Find Quote Report
Poki
Junior Member
**


Posts: 16
Joined: Nov 2006
O.P. RE: How to open group chat windows
Well, thanks, that was really useful.
So, let me see if I undestood, I had to define the global variables just as I did, but...
don't give them any value before objects like Messenger are fully loaded, so the assignment of the variable had to be done maybe in OnEvent_SignInReady(email), because there I can be sure that Messenger object is ready and there would be no problem in assigning the correct value....
(just verbalizing for myself...)
Again, thanks to every one who helped me in this attempt to make a script...I'll be posting it soon.
Seeya.
11-05-2006 11:24 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: How to open group chat windows
quote:
Originally posted by Poki
Well, thanks, that was really useful.
So, let me see if I undestood, I had to define the global variables just as I did, but...
don't give them any value before objects like Messenger are fully loaded, so the assignment of the variable had to be done maybe in OnEvent_SignInReady(email), because there I can be sure that Messenger object is ready and there would be no problem in assigning the correct value....
Absolutely correct (y)
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-05-2006 11:29 PM
Profile PM Find Quote Report
Poki
Junior Member
**


Posts: 16
Joined: Nov 2006
O.P. RE: How to open group chat windows
Well, finally....
It's done.
May I ask you....how do I export my script so is it downloadable and ready to go?
I only have my .js script, but have several friends who won't know how to make it run unless I do something like that.
11-09-2006 03:17 PM
Profile E-Mail PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: How to open group chat windows
quote:
Originally posted by Poki
Well, finally....
It's done.
May I ask you....how do I export my script so is it downloadable and ready to go?
I only have my .js script, but have several friends who won't know how to make it run unless I do something like that.
Seek the Messenger Plus! Live Scripting documentation for Packing your Script. To submit your script to the Scripts Database read Submit Instructions.

This post was edited on 11-09-2006 at 03:26 PM by Felu.
11-09-2006 03:24 PM
Profile E-Mail PM Web Find Quote Report
Plan-1130
Full Member
***

I keep askin' myself: why?

Posts: 142
73 / Male / –
Joined: Feb 2005
RE: How to open group chat windows
You can get a script packager of MPScripts Tools website, this basicly does all the work for you
My Scripts: UltimatFlooder, Advanced PSM Chat, PlusPrivacy, PlusRemote

[Image: Plan-1130.png]
11-09-2006 03:34 PM
Profile E-Mail PM Find Quote Report
Pages: (4): « First « 1 2 [ 3 ] 4 » Last »
« 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