What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [HELP] I need some help with my script

[HELP] I need some help with my script
Author: Message:
Otacon
New Member
*


Posts: 11
Joined: Oct 2008
O.P. [HELP] I need some help with my script
OK, I made a script which reads text from a .txt file(amipOutput.txt) and sets it as my PM. In case that file is empty, it reads another file(PM.txt). And sets the text inside that as my PM. The script is working perfectly except for one thing: after some time of running, i get a "End of file" error in the debugger and the script stops. Here's my code:

quote:
var y = 0;
function OnEvent_Initialize(MessengerStart)
{
    addTimer();
}
function addTimer()
{
    MsgPlus.AddTimer("pm",1000);
}
function OnEvent_Timer(pm)
{
    if(y == 0)
    {
        var fso1, f, s;
        fso1 = new ActiveXObject("Scripting.FileSystemObject");
        f = fso1.GetFile("C:\\amipOutput.txt");
        s = f.size;
       
        if(s == 0)
        {
            setPm();
            addTimer();
        }
        else
        {
            setAmip();
            addTimer();
        }
       
    }
}
function setPm()
{
    var fso, ts, a, a1, f1, txt;
    var ForReading = 1;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    ts = fso.OpenTextFile("C:\\PM.txt",ForReading);
    a = ts.ReadAll();
    ts.Close();
    a = MsgPlus.RemoveFormatCodes(a);
    Messenger.MyPersonalMessage = a;
    a = 0;
}
function setAmip()
{
    var fso2, ts2, b, b1, f1, txt;
    var ForReading = 1;
    fso2 = new ActiveXObject("Scripting.FileSystemObject");
    ts2 = fso2.OpenTextFile("C:\\amipOutput.txt",ForReading);
    b = ts2.ReadAll();
    ts2.Close();
    b = MsgPlus.RemoveFormatCodes(b);
    Messenger.MyPersonalMessage = b;
    b = 0;
}
function OnEvent_MenuClicked(sMenuId, sLoc, sWnd)
{
    if(sMenuId=="on")
    {
        addTimer();
        var y = 0;
    }
    if(sMenuId=="off")
    {
        var y = 1;
        MsgPlus.CancelTimer("pm");
        setPm();
    }
}


function OnGetScriptMenu()
{

    var myMenu = new PlusMenu;
   
    myMenu.addItem("on", "Turn AMIP PM on");
    myMenu.addItem("off", "Turn AMIP PM off");
   
    return myMenu.build();
}

Please, it's driving me crazy, I want to finally get it to work.
10-12-2008 02:18 PM
Profile E-Mail PM Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
RE: [HELP] I need some help with my script
Try adding a loop perhaps? ^o)
10-18-2008 03:52 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [HELP] I need some help with my script
"ForReading" is a constant, but it isn't defined in Plus! scripts. You'll have to assign its value yourself at the very top of your script, so add:
code:
var ForReading = 1
at the top of your script.

But more important: a timer interval of 1000 is waaay too low! No wonder you end up with troubles, because:
  1. Messenger itself doesn't allow you to update it that frequently. Okay, it may look like it works, but it won't actually update on the servers.
  2. the file is being read too often! Every second, it has to be opened, read and closed again. That's just way too much.
My recommendation: change the interval. Make it at least 15 seconds (15000 milliseconds) or, to spare your contacts from flooding their logs with your personal message updates, make it one minute (60000 ms) or more. There should really be no reason to update your PSM that often.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-18-2008 04:05 PM
Profile E-Mail PM Web Find Quote Report
Otacon
New Member
*


Posts: 11
Joined: Oct 2008
O.P. RE: [HELP] I need some help with my script
Thanks for the help, much appreciated, will test it now. The reason for the low interval is that the first file that is read is actually a output file from AMIP, a iTunes plugin that writes what I'm currently listening to. So what I wanted to do is make the script look for changes in that files every second in case I change the song I'm listening to. For that purpose, one minute is just too much, but if I still have problems, I guess that will be the only way to solve it.

Anyways, thanks for all the help.
10-18-2008 04:14 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [HELP] I need some help with my script
If you want to display what you're playing in iTunes, why don't you simply use this script: [release] Music now playing? That script gets the information directly from iTunes, without the need of a plug-in who writes the information to a file first.

I mean: why would you want to re-invent the wheel? :P Give it a try and see how it works out for you. :)

This post was edited on 10-18-2008 at 04:20 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-18-2008 04:19 PM
Profile E-Mail PM Web Find Quote Report
Otacon
New Member
*


Posts: 11
Joined: Oct 2008
O.P. RE: [HELP] I need some help with my script
Already tried that, didn't work. Messenger Live comes with a integrated plugin for iTunes, and that plugin overwrites any custom input from third-party addons or programs. This approach allows me to have a customized Now Playing status, because it sets my Now Playing status as a regular personal message, so the Live Messenger plugin has nothing to do with it. It would work great if only I could find out what the problem is.

Still can't get it to work, though. Tried setting the delay to 1 minute and tried adding "var ForReading = 1" at the beginning of the script, and I still get the same error. Any more ideas?

This post was edited on 10-18-2008 at 06:16 PM by Otacon.
10-18-2008 06:14 PM
Profile E-Mail PM 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