Shoutbox

[Help] My Problem... - 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: [Help] My Problem... (/showthread.php?tid=62011)

[Help] My Problem... by b0rna on 06-29-2006 at 12:02 PM

Hi,

i will try to be as through as i can with this so you can understand it easier.

im not very advanced in programming and thus i am having this problem.

Here is a function that i have. the variables inside this function hold a Cache of data. A string cache at which every time the timer of 100ms is called empties 1000 charactesr of that cache.

now i can use debug trace and everything works well.

now i want to send this string to the chat window.

//////////////////////////////////////////////////////////////////////////


var count_length = 0;
var chk_end = new Boolean(0);

function OnEvent_Timer(TimerId)
{

var send_string = "";

if (TimerId == "send_timer_folder" && chk_end == 0)
{
send_string = final_final_folder.substr(count_length, 1000);
count_length += 1000;

if (send_string.length < 1)
{
chk_end = 1;
count_length = 0;
ChatWnd.SendMessage("no other folders.");   <<<< Error here ( chatwnd object undefined)
}
else
{
ChatWnd.SendMessage(send_string);    <<<< And here here ( chatwnd object undefined)
Debug.Trace(send_string);
send_string = "";
MsgPlus.AddTimer("send_timer_folder",100);
}
}
}

///////////////////////////////////////////////////////////////////

my question is, how can i write a function, that is called everytime the timer is up, and still have the ChatWnd object inside so i can use the SendMessage(string) command inside that function?


Thanks


RE: [Help] My Problem... by upsfeup on 06-29-2006 at 12:42 PM

You have to define which window to use. Of what contact you want to send the message to!

Ohh and try to find a better name for the topic! My problem doesn't say much about it!


RE: [Help] My Problem... by b0rna on 06-29-2006 at 12:59 PM

ok. but that doesnt really help me much.


RE: [Help] My Problem... by upsfeup on 06-29-2006 at 01:12 PM

Ok! How do you choose the window to send the information? probably another function such as OnEvent_WndMessageReceived. In this function you have a variable called ChatWnd so you write a global variable.

code:
targetWindow = ChatWnd
Then on your timer function you can use
code:
targetWindow.SendMessage("no other folders.");

RE: [Help] My Problem... by matty on 06-29-2006 at 01:14 PM

Ok the problem that your having is that ChatWnd isn't defined as anything. If you look at other examples or even a function (example : )

code:
OnEvent_ChatWndCreated(
    [object] ChatWnd
);

You see how ChatWnd is defined as an object. This is there because Plus! passes the chat window object to the function. This cannot be used the way you are doing it. If you make a global variable
code:
var ChatWnd;

And pass the ChatWnd from the OnEvent_ChatWndCreated to our global ChatWnd then you can use it. However this will overwrite the previous windows.

So if you were sending these messages to Person X and you open a conversation with Persion Y you will be sending them to Person Y and not Person X.

Hope that explains why your getting the error and how you can possibly fix it.