What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Script->DownloadFile function

Script->DownloadFile function
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Script->DownloadFile function
You don't have to call the OnEvent_DownloadFileComplete event, you have to define that function!

Basically, Plus! acts like this:
  1. When you call DownloadFile with a code like this:
    code:
    var DownloadStarted = MsgPlus.DownloadFile("http://www.mysite.com/myscript.plsc", MsgPlus.ScriptFilesPath + "\\MyScript.plsc");
    Plus! will start the download. Meanwhile, your script will continue, it will not wait until the download is finished to start executing the code again. This asynchronous behaviour prevents Messenger from freezing while the file is being downloaded.
  2. When the download is done, Plus! will look in your script files for an OnEvent_DownloadFileComplete function definition. It'll then call that function with the parameters of the download: the URL it was downloaded from, the file path it was saved to and a boolean indicating if the download was successful. You can use these given parameters in your function definition to do stuff with it, like moving or opening the downloaded file:
    code:
    function OnEvent_DownloadFileComplete(Url, OutFile, Success) {
       if(Url == "http://www.mysite.com/myscript.plsc") {
          if(Success) {
             //The download of myscript.plsc was succesful.
             //You can now use the OutFile variable to do something with your downloaded file.
             Debug.Trace("Downloaded file saved in: "+OutFile);
          } else {
             //Uh-oh, the download failed!
             //You can add in some error-handling here, to notify the user what has happened.
             Debug.Trace("The download failed!");
          }
       }
    }
Note that you can have only one OnEvent_DownloadFileComplete function in your script, so if you have to download multiple files, you'll have to add another check in the function for that Url. I'm sure you'll figure that out if you ever need it. ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
04-30-2008 01:28 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Script->DownloadFile function - by apex on 04-29-2008 at 07:23 PM
RE: Script->DownloadFile function - by roflmao456 on 04-29-2008 at 07:53 PM
RE: Script->DownloadFile function - by apex on 04-29-2008 at 08:07 PM
RE: Script->DownloadFile function - by Matti on 04-30-2008 at 01:28 PM
RE: Script->DownloadFile function - by apex on 05-01-2008 at 09:34 AM
RE: Script->DownloadFile function - by apex on 05-01-2008 at 09:48 AM
RE: Script->DownloadFile function - by Felu on 05-01-2008 at 10:27 AM
RE: Script->DownloadFile function - by CookieRevised on 05-02-2008 at 05:45 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