What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » instantiate plus! scripting objects from outside?

instantiate plus! scripting objects from outside?
Author: Message:
Silentdragon
Full Member
***

Avatar
if(life==null && wrists) EmoAlert();

Posts: 148
Reputation: 2
34 / Male / –
Joined: Jun 2006
RE: instantiate plus! scripting objects from outside?
code:
/* File modification dates registry */
var FileModificationDates = [];
/**
* Listen for file modification
*
* @param string FilePath the file to observe
* @param function Callback function to call when the file is modified
* @return boolean
*
* @note : Callback function should take one argument which is the the path of the file
*/
function ListenForFileModification(FilePath, Callback) {
    var DateLastModified = GetFileModificationDate(FilePath);
    if (DateLastModified === false) return false;
   
    Callback = Callback || function(FilePath) {};
    FileModificationDates[FilePath] = {
        file        : FilePath,
        date        : DateLastModified,
        callback    : Callback
    }
    MsgPlus.AddTimer('LSTN_FileModification_' + FilePath, 100);
    return true;
}
/**
* Get the file modification time
*
* @param string FilePath the file
* @return string
*
* @note : returns false if file does not exist
*/
function GetFileModificationDate(FilePath) {
    var FileSystem    = new ActiveXObject('Scripting.FileSystemObject');
    if (!FileSystem.FileExists(FilePath)) return false;
    var File = FileSystem.GetFile(FilePath);
    return '' + File.DateLastModified + '';
}
/* common Timer event handler */
function OnEvent_Timer(TimerId) {
    var TimerMatchLSTN = TimerId.match(/^LSTN_FileModification_(.+)$/);
    if (TimerMatchLSTN.length && FileModificationDates[TimerMatchLSTN[1]]) {
        var FilePath = TimerMatchLSTN[1];
        var DateLastModified = GetFileModificationDate(FilePath);
        if (DateLastModified === false) return false;
       
        if (DateLastModified != FileModificationDates[FilePath].date) {
            FileModificationDates[FilePath].callback(FilePath);
            FileModificationDates[FilePath] = undefined;
            return true;
        }
        MsgPlus.AddTimer('LSTN_FileModification_' + FilePath, 100);
        return true;
    }
}
// usage example :
ListenForFileModification(MsgPlus.ScriptFilesPath + '\\file.txt', function(FilePath){Debug.Trace('File modified : ' + FilePath)});

There's the code from MPScripts.net
08-08-2006 11:18 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 11:15 AM
RE: instantiate plus! scripting objects from outside? - by RaceProUK on 08-08-2006 at 12:20 PM
RE: instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 12:24 PM
RE: instantiate plus! scripting objects from outside? - by markee on 08-08-2006 at 12:33 PM
RE: instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 12:40 PM
RE: instantiate plus! scripting objects from outside? - by Veggie on 08-08-2006 at 12:42 PM
RE: instantiate plus! scripting objects from outside? - by AberNStein on 08-08-2006 at 03:36 PM
RE: instantiate plus! scripting objects from outside? - by Intosia on 08-08-2006 at 03:37 PM
RE: instantiate plus! scripting objects from outside? - by deAd on 08-08-2006 at 04:01 PM
RE: RE: instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 05:52 PM
RE: instantiate plus! scripting objects from outside? - by Intosia on 08-08-2006 at 04:08 PM
RE: instantiate plus! scripting objects from outside? - by matty on 08-08-2006 at 04:18 PM
RE: instantiate plus! scripting objects from outside? - by deAd on 08-08-2006 at 04:19 PM
RE: instantiate plus! scripting objects from outside? - by Intosia on 08-08-2006 at 04:24 PM
RE: instantiate plus! scripting objects from outside? - by AberNStein on 08-08-2006 at 04:26 PM
RE: RE: instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 05:59 PM
RE: RE: RE: instantiate plus! scripting objects from outside? - by AberNStein on 08-08-2006 at 06:36 PM
RE: RE: instantiate plus! scripting objects from outside? - by J-Thread on 08-08-2006 at 09:50 PM
RE: instantiate plus! scripting objects from outside? - by Veggie on 08-08-2006 at 05:45 PM
RE: instantiate plus! scripting objects from outside? - by deAd on 08-08-2006 at 10:18 PM
RE: RE: instantiate plus! scripting objects from outside? - by rh on 08-08-2006 at 10:47 PM
RE: instantiate plus! scripting objects from outside? - by Shondoit on 08-08-2006 at 10:55 PM
RE: instantiate plus! scripting objects from outside? - by Silentdragon on 08-08-2006 at 11:18 PM
RE: instantiate plus! scripting objects from outside? - by Shondoit on 08-08-2006 at 11:23 PM
RE: RE: instantiate plus! scripting objects from outside? - by AberNStein on 08-09-2006 at 04:49 AM
RE: instantiate plus! scripting objects from outside? - by rh on 08-09-2006 at 07:38 AM
RE: instantiate plus! scripting objects from outside? - by Intosia on 08-09-2006 at 09:08 AM


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