Im making my first script (and I keep adding to it when i find out how to do something new...)
Ive just started to get this error, and cant see why... Here's the debugging:
code:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Error: unknown (code: -2147418113)
File: Status Checker.js. Line: 94.
Function OnEvent_Timer returned an error. Code: -2147352567
Function called: OnEvent_Signin
Function called: OnGetScriptMenu
Function called: OnEvent_Uninitialize
Script has been stopped
Heres the (majority of) the code:
code:
var originalPSM;
var originalPSM1;
var idleSeconds;
var isIdle;
var isBusy;
var PSMnumber;
var PSM1number;
var PSMtype;
var seconds = 60;
var allowed = 1;
function OnEvent_Initialize(MessengerStart)
{
idleSeconds = 0;
isIdle = false;
isBusy = false;
MsgPlus.AddTimer('rotate', seconds * 1000);
}
function OnEvent_Signin(sEmail)
{
MsgPlus.DisplayToast("Status Checker,","Status Checker Running...");
}
function OnEvent_Uninitialize(MessengerExit)
{
}
function updateMessage() {
if(allowed==1) {
if(PSMtype==1) {
if(PSMnumber==1) {
originalPSM = "PM1";
PSMnumber=2;
} else if(PSMnumber==2) {
originalPSM = "PM2";
PSMnumber=3;
} else {
originalPSM = "PM3";
PSMnumber=1;
}
Messenger.MyPersonalMessage = originalPSM;
PSMtype=2;
} else {
if(PSM1number==1) {
originalPSM1 = "PM1 - type 2";
PSM1number=2;
} else {
originalPSM1 = "PM2 - type 2";
PSM1number=1;
}
Messenger.MyPersonalMessage = originalPSM1; ///------This is line 94 (causing the error)
PSMtype=1;
}
}
}
function OnEvent_MyStatusChange(NewStatus) {
if(allowed==1) {
if( NewStatus == 7 || NewStatus == 6 ) {
Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! 0hrs:0mins:0secs";
MsgPlus.AddTimer( "incIdle", 1000 );
MsgPlus.AddTimer( "updateDisplay", 6000 );
isIdle = true;
isBusy = false;
MsgPlus.DisplayToast("Status Checker","Idle/Away State Activated");
} else if(NewStatus == 4) {
Messenger.MyPersonalMessage = "Text me! I'm in a full screen app and msngr alerts are off! ";
isBusy = true;
isIdle = false;
idleSeconds = 0;
MsgPlus.DisplayToast("Status Checker","Busy State Activated");
} else {
isIdle = false;
isBusy = false;
idleSeconds = 0;
updateMessage();
MsgPlus.DisplayToast("Status Checker","Normal State Activated");
MsgPlus.AddTimer('rotate', seconds * 1000);
}
}
}
function OnEvent_Timer(sTimerId)
{
if( isIdle == false && isBusy == false) {
updateMessage();
MsgPlus.AddTimer('rotate', seconds * 1000);
return 0;
} else if( sTimerId == "incIdle" ) {
if(isIdle==true) {
idleSeconds ++;
MsgPlus.AddTimer( "incIdle", 1000 );
}
}
else if( sTimerId == "updateDisplay" ) {
if(isIdle==true) {
var cIdleSeconds = idleSeconds;
var idleHours = 0;
var idleMinutes = 0;
while( cIdleSeconds > 59 ) {
cIdleSeconds -= 60;
idleMinutes ++;
}
while( idleMinutes > 59 ) {
idleMinutes -= 60;
idleHours ++;
}
Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! "+idleHours+"hrs:"+idleMinutes+"mins:"+cIdleSeconds+"secs";
MsgPlus.AddTimer( "updateDisplay", 6000 );
}
}
}
function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('pmrotate', 'Rotate your Personal Message');
if(allowed==1) {
AddCommand('pmtoggle', 'Disable Automatic PM Changes');
} else if(allowed==0) {
AddCommand('pmtoggle', 'Enable Automatic PM Changes');
}
}
return oCommand.ExportCommands();
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) {
var _command = RegExp.$1.toLowerCase();
var _param = RegExp.$2;
switch (_command) {
case 'pmrotate':
if ( _param !== '' ) {
seconds = _param;
} else {
updateMessage();
}
return '';
break;
case 'pmtoggle':
if(allowed==1) {
allowed=0;
MsgPlus.DisplayToast("Status Checker","Disabled");
} else if(allowed==0) {
allowed=1;
MsgPlus.DisplayToast("Status Checker","Enabled");
}
return '';
break;
}
}
}
function OnGetScriptMenu(nLocation){
var oMenu = new ScriptMenu();
if(allowed==1) {
oMenu.AddItem('/pmtoggle', 'Disable');
} else if(allowed==0) {
oMenu.AddItem('/pmtoggle', 'Enable');
}
oMenu.AddItem('/pmrotate', 'Rotate PM');
return oMenu.ExportMenu();
}
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}
I only took out the parts that I am sure have no significance...
Thanks for the help
The script does not work, until the script is stopped, and re-started again - I dont know why.
Nick