What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [HELP]File listing and getting it to work

[HELP]File listing and getting it to work
Author: Message:
Vector
New Member
*


Posts: 3
Joined: Aug 2006
O.P. Roll Eyes  [HELP]File listing and getting it to work
hi there!
i'm realy new to mpl! scripting and i need some help with getting this to work :)

i got it from mpscripts.net

i'm trying to list out the files from directory, and send the list of files in the chat.

this is what i got yet:


function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
    if(Message.match("^!list"))
    {
        var folder = Message.substr(6);
        var type = "1"
        //ChatWnd.SendMessage(folder);
        var stuff = ListFolders();
        ChatWnd.SendMessage(stuff);
    }
}

//Folder = folder to read files from
//Type: 0 = Full Path; 1 = Filename Only
//Returns array if files found otherwise false
function ListFiles(folder,type) {
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var dirFiles = new Array();
    if(fso.FolderExists(folder)) {
        f = fso.GetFolder(folder);
        files = new Enumerator(f.Files);
        if(files.atEnd()) return false;
        for (var i = 0; !files.atEnd(); files.moveNext())
        {
            if(type == 1)
                dirFiles[i++] = files.item();
            else {
                var temp = "" + files.item();
                var index = temp.lastIndexOf("\\");
                dirFiles[i++] = temp.substr(index+1);
            }
        }
        return dirFiles;
    } else
        return false;
}

i know that there are several thing i'm doing wrong but that is why i'm asking for some help :)

sry for my english and thank you..

This post was edited on 08-28-2006 at 09:55 PM by Vector.
08-28-2006 09:52 PM
Profile E-Mail PM Find Quote Report
Silentdragon
Full Member
***

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

Posts: 148
Reputation: 2
34 / Male / –
Joined: Jun 2006
RE: [HELP]File listing and getting it to work
It needs to be used like this:
code:
var list = ListFiles("C:\\",1);
Debug.Trace("First File in C:\\ is "+list[0]);
That would get a list of all files in C:\ and Debug.Trace the first file in the list.

So in your example you'd need to do this
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
    if(Message.match("^!list"))
    {
        var folder = Message.substr;
        var stuff = ListFolders(folder,1);
        ChatWnd.SendMessage(stuff.join("\r\n"));
    }
}
That would send a list of your files to your contact with each file on its own line.
08-28-2006 10:16 PM
Profile E-Mail PM Web Find Quote Report
Vector
New Member
*


Posts: 3
Joined: Aug 2006
O.P. RE: [HELP]File listing and getting it to work
Thank You! :)
08-29-2006 09:46 PM
Profile E-Mail 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