mIRC Homepage
Posted By: RusselB incorrect count of lines in custom window - 25/09/09 06:12 AM
With this
Code:
alias music {
  var %ticks = $ticks, %a = 1, %b = $disk(0)
  while %a <= %b {
    if !$window(@Music) { .window @Music }
    if $disk(%a).type == fixed {
      noop $findfile($disk(%a).path,*.mp3,0,echo @Music $1-)
    }
    elseif $disk(%a).type = remote {
      noop $findfile($disk(%a).unc,*.mp3,0,echo @music $1-)
    }
    inc %a
  }
  %ticks = $calc($ticks - %ticks)
  var %lines = $line(@music,0)
  echo 11 @music Total lines %lines
  echo 4 @music Total time %ticks milliseconds
  echo 4 @music Average time $calc(%ticks / %lines)
}
the section regarding the fixed drive(s) works fine, but remote drive(s) have a problem.
The information is send to the window, like it's supposed to, but the number of lines is not increased.

On my fixed drives, I have about 5000 mp3 files, and on the remote drive I have about 50000. Thus if this code worked as I expected, it should show a total number of lines of about 55000.

However, it does not, it shows the 5000 count.

Here's hoping someone can figure out what's going on, and what I need to do in order to get a correct count.
Posted By: argv0 Re: incorrect count of lines in custom window - 25/09/09 06:27 AM
have you tried using the recommended bracket and operator syntax?
Could you please point me to where you are referring to, as I can't see anything wrong with the syntax I'm using, and I'm not getting an error message, which I would expect if there was a bracket or syntax error.

Posted By: RoCk Re: incorrect count of lines in custom window - 25/09/09 01:12 PM

He means this
while %a <= %b {

should be this
while (%a <= %b) {

-
and this
if !$window(@Music) { .window @Music }

should be this
if (!$window(@Music)) { .window @Music }

-

and this
if $disk(%a).type == fixed {

should be this
if ($disk(%a).type == fixed) {

-

and this
elseif $disk(%a).type = remote

should be this
elseif ($disk(%a).type == remote) { Your error is probably here.

-

and this
%ticks = $calc($ticks - %ticks)

should be this
var %ticks = $calc($ticks - %ticks)
Posted By: DJ_Sol Re: incorrect count of lines in custom window - 25/09/09 04:59 PM
Have you used echos to determine what drives are found with $disk?

Another thing, why check if the window exists each time through the while loop? Just check to make sure the window is open at the beginning of your alias.

Code:
alias music {
  var %ticks = $ticks, %a = 1, %b = $disk(0)
  if !$window(@Music) { .window @Music }
  while %a <= %b {



So have you verified it has found your network drives?

all of the echoing is showing the correct drives, and the echo in the $findfile sends the information to the custom window.

What doesn't seem to be happening, and I guess I didn't make this clear, is the fact that the variable to echo the number of lines from the window seems to be ignoring any lines that come from the remote drive, in spite of the fact that I can see the lines being echoed to the custom window.
The problem that I'm encountering with your script is that the echo'd lines seem to exceed the buffer limit on the @window. Even when I change the /echo to /aline, I still get the buffer being exceeded (though at a higher number of lines for some reason).

Maybe try changing the @window to be a listbox (-l switch).

-genius_at_work
hmm.. ok, I'll try that and see what happens.

In the long run I don't plan on using a custom window, but thought it would be a good way to be able to test my code without ruining the display/conversation flow of my channel windows.

So much for that idea. Adding the -l switch made my mIRC lockup.

Now possibly I failed to find/read about a switch or other requirement for using a listbox window, but I don't think I did.

Here's my current code that locked up mIRC. Removing the -l switch allows the code to work, but with the same problem.
Code:
alias music {
  var %ticks = $ticks, %a = 1, %b = $disk(0)
  if !$window(@Music) { .window -l @Music }
  while %a <= %b {
    echo @Music $disk(%a).path
    if $disk(%a).type == fixed {
      noop $findfile($disk(%a).path,*.mp3,0,echo @Music $1-)
    }
    elseif $disk(%a).type = remote {
      noop $findfile($disk(%a).unc,*.mp3,0,echo @music $1-)
    }
    inc %a
  }
  %ticks = $calc($ticks - %ticks)
  var %lines = $line(@music,0)
  echo 11 @music Total lines %lines
  echo 4 @music Total time %ticks milliseconds
  echo 4 @music Average time $calc(%ticks / %lines)
}

You might be able to write the results to a txt file rather than a @window. The file handler commands (/fopen /fwrite etc) should be much faster than /write.

-genius_at_work
© mIRC Discussion Forums