recursion limit when creating file list of harddrive

JB sundown at pacifier.com
Wed Oct 28 14:36:47 EDT 2015


Here is a different mouseUp handler you
can put in a field.

on mouseUp
   if target = empty then
      answer folder "Pick a folder you want to walk:"
      put it into whatFolder
      set cursor to watch
      put directoryListing(whatFolder,2) into target
      exit to top
   end if
   if the controlKey is down and the optionKey is down then
      put empty into target
      exit to top
   end if
   if the controlKey is down then
      put word 2 of the clickline into tLine
      put line tLine of target into whatFolder
      set itemDel to "/"
      delete last item of whatFolder
      set cursor to watch
      put directoryListing(whatFolder,2) into target
      exit to top
   end if
   if the optionKey is down then
      set itemDel to "/"
      sort lines of target descending by last item of each
      exit to top
   end if
   if the commandKey is down then
      set itemDel to "/"
      sort lines of target ascending by last item of each
      exit to top
   end if
   put word 2 of the clickline into tLine
   put line tLine of target into whatFolder
   set cursor to watch
   put directoryListing(whatFolder,2) into target
end mouseUp

function directoryListing whatFolder,c
     put whatFolder & cr into R
     set the directory to whatFolder
     if c = 0 or the result is not empty then return R
     put the files into tFileList
     sort tFileList
     replace cr with cr & whatFolder & "/" in tFileList
     put whatFolder & "/" & tFileList & cr after R
     put line 2 to -1 of the folders into tDirList
     sort tDirList
     repeat for each line L in tDirList
           put directoryListing((whatFolder & "/" & L),(c-1)) after R
     end repeat
     return R
end directoryListing


JB


More information about the use-livecode mailing list