What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Multiple Function Call/callbacks

Multiple Function Call/callbacks
Author: Message:
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. Multiple Function Call/callbacks
Hey guys,

I need advice yet again.  I have written a script which checks an html interface and outputs the information scraped to a contact.  Or rather, thats my intention.  I've spent 10 mins trying to write this, but it doesnt make sense even to me, so please excuse the random code.

code:
function AzureusInfoFetch()
{
    http = new ActiveXObject("Microsoft.XMLHTTP");
    http.onreadystatechange=AzureusInfoRead();
    http.open("GET", "http://" + "192.168.0.2" + ":" + "6885/index.tmpl", true, "StevieD", "leroux should edit his password out of scripts he posts on the forums");
    http.send(null);
}
               

function AzureusInfoRead()
{
     if ((http.readyState == 4) && (http.status == 200))
    {
        var Azureus = AzureusInfo(http.responseText);
        Debug.Trace(Azureus);
    }
    http.close;
}

function AzureusInfo(text)
{
    if (text.indexOf('<tr id="r'+n) > -1)
    {
        XBMCArtist = text.substring(text.indexOf('<tr id="r1"'), text.length);
        XBMCArtist = XBMCArtist.substring(0, XBMCArtist.indexOf('</tr>')+5);
    XBMCArtist=XBMCArtist.split("<td");
.....
}

Theres various formatting in this code, and it all works according to debug, but the basic point I need is for it to be called by a contact.  I'm looking for the function AzureusInfoFetch() to be called when a contacts sends the message "!azureus", and then once all of the data is fetched and formatted through the other functions will send it back to the contact.  I don't suppose anyone can suggest a way to do this, because I just dont seem to be able to get my head around it.

Cheers

[Sorry for the misleading topic name earlier.  I got confused while writing and ending up changing what I needed help with.  I wasnn't trying to trick people into viewing. Sorry]

This post was edited on 11-30-2007 at 05:20 AM by ArkaneArkade.
[Image: adsig.jpg]
11-29-2007 12:44 PM
Profile E-Mail PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Multiple Function Call/callbacks
er just check for it on received message

code:
function OnEvent_ChatWndReceiveMessage (wnd, origin, msg){

switch(msg){
case "!xxx" : wnd.SendMessage(AzureusInfoFetch()); break;
}


}



(the function name may be incorrect, since I'm unable to download the scripting docs here :( )
[Image: dt2.0v2.png]      Happy Birthday, WDZ
11-30-2007 12:30 AM
Profile PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
RE: Multiple Function Call/callbacks
quote:
Originally posted by -dt-
er just check for it on received message

code:
function OnEvent_ChatWndReceiveMessage (wnd, origin, msg){

switch(msg){
case "!xxx" : wnd.SendMessage(AzureusInfoFetch()); break;
}


}



(the function name may be incorrect, since I'm unable to download the scripting docs here :( )
That is very silly as the only way it will work (due to async) is to freeze messenger while it gets it :dodgy:

What you need to do is parse the chat window object through all of your functions as an extra parameter and then at the end of AzureusInfo() you can send it to that chat window using the SendMessage method of that chat window object you parsed through.  I would edit the code to show you but I'm feel lazy :P

This post was edited on 11-30-2007 at 03:27 AM by markee.
[Image: markee.png]
11-30-2007 03:27 AM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Multiple Function Call/callbacks
quote:
Originally posted by markee
quote:
Originally posted by -dt-
er just check for it on received message

code:
function OnEvent_ChatWndReceiveMessage (wnd, origin, msg){

switch(msg){
case "!xxx" : wnd.SendMessage(AzureusInfoFetch()); break;
}


}



(the function name may be incorrect, since I'm unable to download the scripting docs here :( )
That is very silly as the only way it will work (due to async) is to freeze messenger while it gets it :dodgy:
:P
:P it was just a quickly written example, I assumed that all he wanted to know was how to have data sent back when someone says !xxx. ;o but it seems now that I misread his post, and he wanted to know how to send the message from the callback ;o

code:

function AzureusInfoFetch(wnd)
{
http = new ActiveXObject("Microsoft.XMLHTTP");
http.onreadystatechange=function(){
if ((http.readyState == 4) && (http.status == 200))
{
var Azureus = AzureusInfo(http.responseText);
wnd.SendMessage(Azureus);
}
http.close();

}
http.open("GET", "http://" + "192.168.0.2" + ":" + "6885/index.tmpl", true, "StevieD", "lolpassword");
http.send(null);
}



function AzureusInfo(text)
{
if (text.indexOf('<tr id="r'+n) > -1)
{
XBMCArtist = text.substring(text.indexOf('<tr id="r1"'), text.length);
XBMCArtist = XBMCArtist.substring(0, XBMCArtist.indexOf('</tr>')+5);
XBMCArtist=XBMCArtist.split("<td");
.....
}


function OnEvent_ChatWndReceiveMessage (wnd, origin, msg){

switch(msg){
case "!xxx" : AzureusInfoFetch(wnd); break;
}


}


that should work ;o


This post was edited on 11-30-2007 at 05:29 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
11-30-2007 03:37 AM
Profile PM Web Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: Multiple Function Call/callbacks
OK, that worked brilliantly.  Thanks a lot :D  I should have thought of it, but I'm not sleeping and so tired I cant even spell my name right (seriously).  Also, thanks to whoever removed the password from my post - I can't believe I did that.

Cheers as always guys :D

[Edited to remove the horrendous spelling]

On another thought, is there a way for me to return multiple replies from the same function, or would everything need to be done in multiple global vars.

eg.

function SendInfo(){
SetInfo();
Messenger.SetNick(returned info[1]);
Messenger.SetPSM(returned info[2]);
)

function SetInfo(){
info[1] = "Stefan Leroux";
info[2] = "Scripting God (LOL)";
}

I know the setnick/setpsm dont work, but its just for an example.  Is there any way to do it?

Thanks

This post was edited on 12-01-2007 at 02:55 AM by ArkaneArkade.
[Image: adsig.jpg]
11-30-2007 10:27 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Multiple Function Call/callbacks
Sure, just make the function return an array! :)

code:
function SendInfo() {
   var arrayInfo = SetInfo();
   Messenger.MyName = arrayInfo[0];
   Messenger.MyPersonalMessage = arrayInfo[1];
}

function SetInfo() {
   var returns = new Array();
   returns[0] = "Stefan Leroux";
   returns[1] = "Scripting God (LOL)";
   return returns;
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-01-2007 09:15 AM
Profile E-Mail PM Web Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
38 / Male / Flag
Joined: Mar 2007
O.P. RE: Multiple Function Call/callbacks
Brilliant.  I'll get right on that.  Thank you Mattike.
[Image: adsig.jpg]
12-01-2007 09:24 AM
Profile E-Mail 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