IllogicTC commented on a Page, MP3 Player  -  Apr 10, 2011
alias listname {
  var %b 0 , %c $lines($lp_plist) , %x
  .fopen -o nlist $lp_nlist
  while (%b < %c) {
    inc %b
    %x = $nopath($read($lp_plist,%b))
    .fwrite -n nlist $left(%x,$calc($len(%x) - 4))
  }
  .fclose *nlist*
}

Above I have posted an alias from my LimePlayer script that handles writing the name list. Notice up top, that .fopen opens up a new file (-o, you could also use -n but it will not overwrite the file if it already exists), and that there is an internal name identified for mIRC's use (nlist). After that, it cycles through everything it needs with a while loop, and .fwrites everything to "nlist". When done, .fclose will release the file from mIRC so it can be opened by other programs again.

Using this format, you can cycle through everything found in your $sdir() check and write it much quicker, as mIRC's standard write command basically opens the file, writes, closes. Repeat and repeat. With fopen and fclose, it will hold it open which greatly reduces the time used on large amounts of data.

Also, by using the $fread() command you can quicken the pace at which mIRC populates the playlist control in the dialog. I would suggest using /filter here, but since it performs an operation on the item being read before doing its did -a, File Handling could benefit this area as well. For $fread(), it will read until the next $crlf-terminated line, so in essence it will read one line of the text at a time, and will automatically read the next area without the need for commanding it to read a specific line. In essence, it's like a record player. If each line in a text file were a song on a record player, it would work the same. It will only cycle through all the "songs", unless you manually placed the "needle" somewhere else using /fseek.

If you need more help with this, use /help /fopen and it will have everything you need on one page. I taught myself file handling just with the help file, so it isn't all that difficult to implement after a couple of reads and test aliases ^_^

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.