[Help] Need help with list of files in array... - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] Need help with list of files in array... (/showthread.php?tid=61510)
[Help] Need help with list of files in array... by b0rna on 06-26-2006 at 07:04 AM
Hi!
im writing a file server script for the new plus, sorta like the xdcc in irc, where the user can see a list of files in the chat windows and request them and they will be sent to them through the chat like a normal file transfer.
I have dumped file names, paths, attributes, etc... in arrays and i want to send a rather large number of files to choose from to the user.
now msn has a maximum amount of characters and lines that can be sent per message, lets say there are 100 music files in my array.
if i use the SendMessage command and give it my array as the parameter, this is what the message will look like:
D:\Music\Music\#04 - Creed - With Arms Wide Open.mp3,D:\Music\Music\(01) Justin Timberlake - Senorita.wma,D:\Music\Music\(09) Joe Budden - Fire (ft. Busta Rhymes).wma,D:\Music\Music\(10) Andre 3000 - Roses.wma,D:\Music\Music\(10) Tyrese - all ghetto ...
and etc...
now removing the paths and numbering the files all that i will do later on.
my question is, how can output this array so that each file will come on a new line and they will all be sent in one message, untill the capacity of that message is reached, and the rest follow in the next message...
sort of like this.
Example User Says:
D:\Music\Music\#04 - Creed - With Arms Wide Open
D:\Music\Music\(01) Justin Timberlake - Senorita.wma
D:\Music\Music\(09) Joe Budden - Fire.wma
D:\Music\Music\(10) Andre 3000 - Roses.wma
D:\Music\Music\(10) Tyrese - all ghetto
upto the maximum number of lines...
Example User Says:
and the rest of the files...
thank you.
RE: Need help with list of files in array... by can16358p on 06-26-2006 at 07:15 AM
I think max. number was 1100 chars. Let's consider it as that.
You may use a for loop. Or even two.
Make a for loop that will add the text (in this case file paths) to the message, and another for adding those messages to another array which contains the mesages to be sent.
Let sendstr be the message going to be sent.
More detailed step by step:
Make array of song names (you did this one)
Make another array which will hold the strings to be sent.
Make an empty string
Make a loop that will;
Check if the string + next item on the first array (the one with songs names) exceeds 1100 chars, if doesn't exceed, add the text (don't also forget to add line breaks etc.), if exceeds, put the string to the second array (messages to be sent/forget indexing, just use push method), empty the string, and continue the loop until the first array is empty.
Ok, now, read that sentence slowly
After this is easy, you'll just send the messages until the second array is empty, each item as one message.
RE: [Help] Need help with list of files in array... by -dt- on 06-26-2006 at 07:30 AM
this is the method i use , just make it into one string and use this function
code: /*
* ---------------------------
* Void sendPartedMessage (chatWnd wnd, String str, Int length)
* splits a string into parts (decided by length) and sends them
* by -dt-
* ----------------------------
*/
function sendPartedMessage(wnd, str,length){
if(str.length > length){
var part;
while(str.length >= length){
part = str.substr(0,length);
str = str.substr(part.length);
wnd.SendMessage(part);
}
wnd.SendMessage(str);
}else{
wnd.SendMessage(str);
}
}
RE: [Help] Need help with list of files in array... by b0rna on 06-26-2006 at 07:44 AM
thank you both kindly workin on that now.
RE: [Help] Need help with list of files in array... by mathieumg on 06-26-2006 at 11:46 AM
You might be interested by this: http://shoutbox.menthix.net/showthread.php?tid=61404
|