First, you'd save a lot of time by checking total directories (unless you're removing them as well as adding them).

Code:
if ($finddir(c:\temp\,*,0,1) != %LastTotalDirs) { ; do whatever only if true }


You can, of course, remove the 1 if you want to also check total subdirs.


EDIT: Nevermind that. I just noticed that it would then be using $finddir twice, which doesn't really help.

Second, for what you are doing, a hash table is probably the most efficient option.

Code:
alias dirmon {
  noop $finddir(C:\Temp\,*,0,1,CheckDir $1-)
}
alias CheckDir {
  if (!$hget(Directories)) { hmake Directories 50 }
  var %dir = $replace($1-,$chr(32),_)
  if (!$hget(Directories,%dir).item) {
    hadd Directories %dir
    echo new folder found: $1-
  }
}


* If you are also removing directories, then you'll want to set up a removal from the hash table as well as just adding them the way I did here.

Last edited by Riamus2; 03/03/11 06:27 PM.

Invision Support
#Invision on irc.irchighway.net