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
;
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..