For me it made more sense to change the exit value to 1. That way the value is the number of layers you want *including* the directory you specify. So:
put directoryListing("/Users/gcanyon/Desktop",1) -- puts /Users/gcanyon/Desktop That way using either 0 or empty gets the infinite list. The trailing "/" is an interesting point. I checked and the "set the directory" command will happily take a trailing "/" or not, but when you "put the directory" you get no trailing "/" Given that, I'd probably leave it as is, and always assume that the description of a particular directory needs to have the "/" added when adding a filename or directoryname to it. But you could of course go the other way. Making the function flexible to take a trailing "/" or not would require something like: if char -1function directoryListing whatFolder,c if char -1 of whatFolder <> "/" then put "/" after whatFolder put whatFolder & cr into R set the directory to whatFolder if c = 1 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 Tue, Oct 27, 2015 at 3:43 PM, Michael Doub <miked...@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 <gcan...@gmail.com> wrote: >> >> On Sat, Oct 24, 2015 at 7:28 PM, Matthias Rebbe | M-R-D < >>> matthias_livecode_150...@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode