I'm quite bored at the moment so I decided to share a couple of functions that seem to help me out a bit and save time.
This first one is because I was too used to using Flash's trace command. I also like that you can prefix (and suffix) the traced output.
code:
function trace(message){
Debug.Trace("Trace: "+message)
}
This one I deliberatley wanted to be similar to the VB function msgbox. Obviously, I've not given options to set buttons (I only use it for warnings etc)
code:
function msgbox(title, message){
Interop.Call("User32.dll", "MessageBoxW", 0, message, title, 0);
}
I saw a script that shows the percentage of online users so I decided to make a "graphical" version and thought I'd share it
code:
var online;
var offline;
var percent;
var str;
function OnEvent_SigninReady(Email){
doIt(Email);
}
function OnEvent_ContactSignin(Email){
doIt(Email);
}
function OnEvent_ContactSignout(Email){
doIt(Email);
}
function OnEvent_Initialize(MessengerStart){
doIt(Messenger.MyEmail);
}
function doIt(Email){
str="----------------------------------------------------------------------------------------------------";
online=0;
offline=0;
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
if(Contact.Status!=1&&Contact.Status!=0){
online++;
}
offline++;
}
percent = Math.round((online/offline)*100);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}
str=str+" "+percent+"% Online";
Messenger.MyPersonalMessage = str;
Debug.Trace(Email +" caused PSM to update");
}
This might not be "the best way" of doing things (like most of my scripts), but it gets the job done
EDIT: The red segment has been revised due to a SLIGHT error