Below is an alias I wrote to read a list of directories from a window and create the directory structure in an mdx treeview dialog. It also adds the data to a window so it can be referenced later to show the contents of the directory. I'm trying to speed things up but I'm out of ideas, anyone have any suggestions???

-eMpTy


Code:
 
alias MTloaddirs {
  var %blah = $ticks
  var %numlines = $line(@AG7-Data,0)
  var %j = 1
  var %title = $dialog(treetest).title
  while (%j <= %numlines) {
    var %i = 1
    var %line = $replace($line(@AG7-Data,%j),$chr(32),$chr(95)) , %treeline
    var %numtok = $numtok(%line,92)
    while (%i <= %numtok) {
      var %temp = $left(%line,$pos(%line,$chr(92),%i))
      var %temp2 = $left(%line,$pos(%line,$chr(92),$calc(%i - 1)))
      if (!$hget(MTlistview,%temp)) {
        hadd MTlistview %temp 2
        if ((%i != 1) && (%root != 1)) { 
          did -i treetest 1 1 cb root %root %treeline
          did -a treetest 1 + 2 3 0 0 0 $replace($gettok(%temp,$numtok(%temp,92),92),$chr(95),$chr(32))
          aline @AG7-Data2 $chr(9) %root %treeline $chr(9) %temp
        }
        else {
          did -i treetest 1 1 cb root
          did -a treetest 1 + 1 1 0 0 0 $replace($gettok(%temp,$numtok(%temp,92),92),$chr(95),$chr(32))
          aline @AG7-Data2 $chr(9) $+ %treeline $+ $chr(9) %temp
        }
        if (%i != 1) { hinc MTlistview %temp2 }
        else { inc %root } 
      }
      if (%i != 1) var %treeline = %treeline $calc($hget(MTlistview,%temp2) - 1)
      inc %i
    }
    inc %j
    dialog -t treetest %title LOADING ( $+ $int($calc(%j / %numlines * 100)) $+ % $+ )
  }
  dialog -t treetest %title
  echo -s $calc($ticks - %blah)
}