  Title By Mac "(modified by Tommy)"
  DIALOG CREATE,SubDirs - Files List,-1,0,300,200
  DIALOG ADD,BUTTON,LoadDirs,5,5,80,20,"Choose Dir"
  DIALOG ADD,BUTTON,LoadFiles,5,90,80,20,"Load Files"
  rem -- The list box must NOT be SORTED, or files
  rem -- will be scrambled among the subdirectories.
  DIALOG ADD,LIST,LB1,30,5,290,165,sorted
  DIALOG SHOW
  rem -- Add horizontal scroll --
  %z = @sendmsg(@winexists(~LB1),$0194,2000,0)
  LIST CREATE, 1
  list create,2

:EVLOOP
  WAIT EVENT
  goto @event()

:LoadDirsBUTTON
  %d = @dirdlg()
  if %d
    %l = @len(%d)
    if @equal(@substr(%d,%l,%l),\)
      %d = @strdel(%d,%l,%l)
    end 
    list clear,1
    list add,1,%d
    list filelist,1,%d,*
    list assign,LB1,1
  end 
  goto EVLOOP

:LoadFilesBUTTON
  if @not(%d)
    INFO You must load a directory first...@tab()
    goto EVLOOP
  end 
  list clear,2
  if @greater(@count(1),0)
    list seek,1,0
    repeat 
      list filelist,2,@next(1)
    until @greater(@succ(@index(1)),@count(1))
  end 
  LIST ASSIGN,LB1,2
  goto EVLOOP

:CLOSE
  list close,2
  LIST CLOSE, 1
  EXIT 
