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:
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. Script->DownloadFile function
Hi all,
when I let my script download a file with MsgPlus.DownloadFile("link", "location").
He succesfully downloads it, but he remove the extension?
How come he does that? since it's a .plsc file...
Is there a way to add the extension? or dont let him remove it?

Thank You
~APex
04-29-2008 07:23 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
RE: Script->DownloadFile function
you have to add the extension yourself ;)

example:
code:
MsgPlus.DownloadFile("http://update.meetcweb.com/wlmini/WLMini Music Player.plsc", MsgPlus.ScriptFilesPath + "\\WLMini.plsc");
// downloads wlmini music player and stores it in the script folder as "WLMini.plsc"


This post was edited on 04-29-2008 at 07:55 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
04-29-2008 07:53 PM
Profile PM Web Find Quote Report
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: Script->DownloadFile function
OK, thank you!!

well, the Download part works, but the OnEvent_DownloadReady doesnt :S
I now have this:
code:
OnEvent_DownloadFileComplete("http://juleshuls.googlepages.com/PSMChatDutch.plsc", MsgPlus.ScriptFilesPath + "/PSM Chat Dutch/PSM Chat Dutch.plsc")
{
SendFile(MsgPlus.ScriptFilesPath + "/PSM Chat Dutch/PSM Chat Dutch.plsc");
}
What is wrong here? because he keeps saying he needs an object?
04-29-2008 08:07 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / 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
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: Script->DownloadFile function
Hey m8,
First of all, thanks for ur great answer, it now works great and bugless.
If i had 100 posts i would rate yah positive :P

~Apex
05-01-2008 09:34 AM
Profile E-Mail PM Find Quote Report
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: Script->DownloadFile function
Another question :$ :

How can i let the script check if an file is there?

I know have this:
code:
function TurnOn()
{
    Downloadlink = "http://juleshuls.googlepages.com/PSMChatDutch.plsc";
    Outfile = MsgPlus.ScriptFilesPath + ".plsc";
    if (Outfile == true)
    { Downloading == "done";
      Debug.Trace("Hoi");
    } else {
    Debug.Trace("Niet");
    }
}


But the script still returns "Niet" to debug, while file is there!
05-01-2008 09:48 AM
Profile E-Mail PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Script->DownloadFile function
code:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = MsgPlus.ScriptFilesPath + ".plsc";
if(fso.FileExists(file)){
//Code here
// fso.GetFile(name).Delete(true); //If you'd like to delete the already existing file
}
}
05-01-2008 10:27 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Script->DownloadFile function
The reason why your code always returned "Niet":

    Downloadlink = "http://juleshuls.googlepages.com/PSMChatDutch.plsc";
    Outfile = MsgPlus.ScriptFilesPath + ".plsc";

Both Downloadlink and Outfile are strings. Strings are texts, not files, not numbers, not internet links, but simply text. The computer doesn't care what the text means to you or what it should represent, for the computer it is just a bunch of meaningless characters.

If you want to the computer to know that Outfile is a bunch of characters representing a file name, then you need to tell the computer that and you should open the file with that text as parameter. This can be done like Felu showed, with the use of the FileSystemObject ActiveX object.


    if (Outfile == true)

true and false are booleans. And thus since a boolean isn't the same as text, this function will always return false.

This post was edited on 05-02-2008 at 05:46 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-02-2008 05:45 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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