recursion limit when creating file list of harddrive

JB sundown at pacifier.com
Tue Oct 27 19:36:39 EDT 2015


If you have already put a directory listing in
a field and want to click a line to get the list
of that line you can put this code in the field.

on mouseUp
   put word 2 of the clickline into tLine
   put line tLine of target into whatFolder
   put directoryListing(whatFolder,2) --into fld id 342435
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


> On Oct 27, 2015, at 1:32 PM, JB <sundown at pacifier.com> wrote:
> 
> I was not able to get the mouseUp handler to
> work but I got the function to return a list but it
> probably not the same list.  I used this.
> 
> on mouseUp
>    answer folder "Pick a folder you want to walk:"
>    put it into whatFolder 
>  --put directoryListing(fld "directory",round(the thumbposition of scrollbar "depth")) into field "listing"
>    put directoryListing(whatFolder,2) into fld id 342435
> end mouseUp
> 
> Any suggestions?
> 
> JB
> 
> 
> 
>> On Oct 27, 2015, at 12:43 PM, Michael Doub <mikedoub at gmail.com> wrote:
>> 
>> Geoff,
>> 
>> I would suggest replacing the first statement of the function with
>> 
>> if c is empty then put -1 into c    -- set the default to go all the way down
>> put whatFolder & "/" & cr into R  -- add a "/" to directory output so they are more easily parsed later
>> 
>> -= Mike
>> 
>> 
>> On 10/27/15 12:18 PM, Geoff Canyon wrote:
>>> Revised. Now in function form, with error checking and depth control. You
>>> can hand in a positive number to get that number of layers deep, or a
>>> negative number to go all the way down. I tested it on my home directory
>>> and it came back fine (after some time). I haven't (knowingly) tested with
>>> unusual characters.
>>> 
>>> on mouseUp
>>>   put directoryListing(fld "directory",round(the thumbposition of
>>> scrollbar "depth")) into field "listing"
>>> 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
>>> 
>>> 
>>> On Mon, Oct 26, 2015 at 12:00 AM, Geoff Canyon <gcanyon at gmail.com> wrote:
>>> 
>>>> On Sat, Oct 24, 2015 at 7:28 PM, Matthias Rebbe | M-R-D <
>>>> matthias_livecode_150811 at m-r-d.de> wrote:
>>>> 
>>>>> I am using a script snippet which was posted by Scott Rossi to the list
>>>>> and was originally from Geoff Canyon in 2002.
>>>>> http://lists.runrev.com/pipermail/metacard/2002-August/002274.html
>>>>> 
>>>> Man, do I hate looking at my old code...
>>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 




More information about the use-livecode mailing list