Hi there guys.
Thanks Matti!!
I didn't use your exact class. I made my own custom object and changed a few things so I could pass multiple parameters.
But your Idea helped me a lot. Thanks again. Here's what I wrote. Please tell me if you find something wrong.
code:
//This is in TimerFunction.js
//Do Not Edit
var Timers = new Array();
var TimersIndex = 0;
function myTimer(FunctionName, Elapse, Parameter, Parameter2, Parameter3, Parameter4, Parameter5) {
this.FunctionName=FunctionName
this.Elapse=Elapse;
this.TimerIndex=TimersIndex++;
this.Refresh=TimerRefresh;
this.Delete=TimerDelete;
FunctionText=FunctionName + "(";
//Set all parameters
if (typeof Parameter !== "undefined") {
this.Param1=Parameter;
FunctionText+="TimerObj.Param1";
}
if (typeof Parameter2 !== "undefined") {
this.Param2=Parameter2;
FunctionText+=", TimerObj.Param2";
}
if (typeof Parameter3 !== "undefined") {
this.Param3=Parameter3;
FunctionText+=", TimerObj.Param3";
}
if (typeof Parameter4 !== "undefined") {
this.Param4=Parameter4;
FunctionText+=", TimerObj.Param4";
}
if (typeof Parameter5 !== "undefined") {
this.Param5=Parameter5;
FunctionText+=", TimerObj.Param5";
}
this.FunctionText = FunctionText + ")";
//Set Object
Timers[this.TimerIndex]=this;
MsgPlus.AddTimer("myTimer"+this.TimerIndex.toString(), this.Elapse);
}
function TimerRefresh() {
MsgPlus.AddTimer("myTimer"+this.TimerIndex.toString(), this.Elapse);
}
function TimerDelete() {
MsgPlus.CancelTimer("myTimer"+this.Index);
delete Timers[this.Index];
}
function OnEvent_Timer(TimerId) {
if (TimerId.substring(0, 7) === "myTimer") {
var TimerObj=Timers[TimerId.substring(7)];
eval(TimerObj.FunctionText);
}
}