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;
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;
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.