mIRC Home    About    Download    Register    News    Help

Print Thread
#108935 24/01/05 07:43 AM
Joined: Jun 2003
Posts: 92
K
k1ll3rz Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2003
Posts: 92
does anyone know how whilefix.dll is to be used ? is there a certain code i needa use or just put it in my dll folder or wut? thanx for helping.

heres one of my while loops:

alias create.playlist.mp3 {
write -c Remotes\mp3.txt
var %num 1
while (%num < $calc($findfile(%mp3dir,*.mp3,*) + 1)) {
write Remotes\mp3.txt $remove($findfile(%mp3dir,*.mp3,%num),%mp3dir)
inc %num
}
}


Last edited by k1ll3rz; 24/01/05 07:58 AM.

k1ll3rz
#108936 24/01/05 09:21 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
omg omg omg lol no its not that bad.

your code while constructully sound, has a major flaw in it, that is that when doing a $findfile(%mp3dir,*.mp3,*) it processes through the folder and subfolders locating every mp3.
U do this once for every repeat of the loop becuase you scan the folder/subfolders for the total mp3's within the WHILE condition check.
Then inisde the loop you do a similar thing when you ask for the %num'th mp3 it scans from the first one to the %num'th one to get you it.
This results in 1.5 entire folder/subfolder scans for EACH mp3 that you proccessed.

[edit]
Just read the above and I dont know if i explained it well.
amaigine its like you want to write down the name of everyone in another room, so you start at 1 and ask BOB to count the people in the room, he goes counts them , comes back and says 78, so you ask bob to go get person 1's name, he goes in go to person 1 gets there name and comes back, Now your at 2 so u aask Bob to go count the people, he goes and counts them all and comes back and says 78, so u ask bob to go get person number 2's name, he goes in counts people tell he reaches number 2, gets there name,and comes back. Now your at 3 so u aask Bob to go count the people, he goes and counts them all and comes back and says 78, so u ask bob to go get person number 3's name, he goes in counts people tell he reaches number 3, gets there name, you can see where this is going, and how uneconomic it is.

Below is like saying "bob go count the people in the room, and while counting them write there names down"

[edit]

Below is likely the minimal code you can get away with, it uses $findfile's ability to execute a command for each file it finds

Code:
alias create.playlist.mp3 { 
  write -c Remotes\mp3.txt 
  .echo -q $findfile(%mp3dir,*.mp3,*,write Remotes\mp3.txt $remove($1-,%mp3dir))
} 


Now that well be alot faster, but then it might still not be fast enough, so here is how to add whilefix.dll

Code:
alias create.playlist.mp3 { 
  write -c Remotes\mp3.txt 
  .echo -q $findfile(%mp3dir,*.mp3,*,create.playlist.mp3.file $1-)
} 
alias -l create.playlist.mp3.file {
  write Remotes\mp3.txt $remove($1-,%mp3dir))
  dll WhileFix.dll WhileFix
}

I now call an alias that writes the file and then calls whilefix.dll ***NOTE the second "WhileFix" must be capitalised as it shows else it doesnt work***

Unfortunitly in using $findfile, you can still get large delays, becuase it can take considerable time scanning through folders etc that have no matching files, so the alias does not get called, you can change the match text from *.mp3 to *.* and then check inside the called alias, but i find that in most cases this makes the script take a hugely greater time, but not "freeze" mirc. For your app looking in your mp3 folder, i would try the first option then the second one if its still to slow.

Last edited by DaveC; 24/01/05 09:27 AM.
#108937 24/01/05 09:56 AM
Joined: Jun 2003
Posts: 92
K
k1ll3rz Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2003
Posts: 92
thanx... ur code werks but i found a way to do it b4 u posted

alias create.playlist.mp3 {
window -sh @mp3list
var %a = $findfile(%mp3dir,*.mp3,0,aline @mp3list $remove($1-,%mp3dir))
savebuf @mp3list Remotes\Mp3.txt
window -c @mp3list
}


k1ll3rz
#108938 24/01/05 05:53 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Congrates, while your method may seem to some to be odd in that you save to a window then save the window to a file, it may infact be better than what i suggested, as Im not to sure how mirc adds lines to a file using /write, it may copy the entire file to a new copy and add the line, this would be disk intensive, while your script simply uses memory then writes the whole lot at once.

Only thing ill say and its a real minor thing, try out using " .echo -q " instead of " var %a = ", -q means dont echo if .echo was used. So it never shows.

#108939 24/01/05 06:00 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
mIRC's /write command is most likely the equivilent of this:

Code:
alias write {
  .fopen &lt;name&gt; &lt;file&gt;
  .fwrite -n &lt;name&gt; &lt;data&gt;
  .fclose &lt;name&gt;
}


Speaking of file handling, this would probably be the fastest method in this case:

Code:
alias create.playlist.mp3 {
  if (!$fopen(playlist)) {
    .fopen -n playlist Remotes\Mp3.txt
    if ($fopen(playlist)) {
      .echo -q $findfile(%mp3dir,*.mp3,0,.fwrite -n playlist $remove($1-,%mp3dir))
      .fclose playlist
    }
  }
}


New username: hixxy
#108940 25/01/05 02:40 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
That would work fine if the file doesn't exist, once it does exists though the script quietly fails. :tongue:
Code:
    .fopen -[color:red]o[/color] playlist Remotes\Mp3.txt


Link Copied to Clipboard