Re: directory tree -> array
Support has restored the thread - you can find it in the "Talking LiveCode" section of the forums: https://forums.livecode.com/viewtopic.php?f=135&t=33565 -- Richard Gaskin Fourth World Systems Dick Kriesel wrote: On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode wrote: I stumbled across a code challenge for y'all, one that seems seductively simple but I don't think it is: What is the simplest way to build an array that reflects the files and folders within a given folder? There's a discussion about this here: https://forums.livecode.com/viewtopic.php?f=7&t=33565 On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode wrote: We have many handlers that deliver directory trees as lists, but arrays are a different beast. Because the depth is both unknowable and varied, I can't think of a way to do this without resorting to "do". Since that thread vanished last week, and hasn’t returned, I'm offering help here instead. The list of full paths contains enough information to build an array representation of the directory tree. /** Summary: Given a list of full paths, and given the partial path they share, build an array representing the directory structure pPaths: a return-delimited list of full paths pPath: the path that was used to generate the list of full paths Returns (array): A array with a branch node for each folder and a leaf node for each file Description: Eliminate pPath from every line of pPaths. Then insert each line into an array. email subject "directory tree -> array" forum topic "f=7&t=33565" */ function arrayFromPaths pPaths, pPath -- a list of full paths, and the path that was used to generate the list local tPaths, tFile, tArray set the itemDelimiter to "/" put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into tPaths -- eliminate pPath from every full path repeat for each line tPath in tPaths -- insert each file name into the array put the last item of tPath into tFile delete the last item of tPath if tPath is empty then -- the file is in folder pPath put "true" into tArray[ tFile ] else -- the file is in a folder in folder pPath split tPath by slash put "true" into tArray[ tPath ][ tFile ] end if end repeat return tArray end arrayFromPaths on mouseUp local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and folder d, which contains files e and f local tPath = "a/b" -- the shared partial path replace comma with cr in tPaths get arrayFromPaths( tPaths, tPath ) breakpoint end mouseUp If the topic reappears soon, I’ll repost there because reading code is easier there. By, the way, thanks to RG for the bug report on my earlier posting in the now-vanished thread. — Dick ___ 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
Re: directory tree -> array
On 04/02/2020 17:20, Bob Sneidar via use-livecode wrote: Good points. I'll make some changes and resubmit. It never dawned on me that someone would intentionally send an empty path, but it *might* happen accidentally. Also, a path like /Users/BobSneidar being repeated would be very edge case, and as an IT guy I would probably take the computer away from any user that managed to make that happen, but it *could* happen and it's always a good idea to guard against such things. Absolutely :-) There should be a "basic competency test" - if you pass, you get to have a computer; if not, you're limited to an iPad :-) Although "/Users/BobSneidar" is an extremely unlikely case, maybe "/tmp" or "/Users" are example where there is a greater danger the string occurring within the sub-folder names. If you're going to resubmit to the Master Library, then I have one more suggestion (though I realize that it may be ruled out for backwards compatibility). Your function is called 'directorylisting', but it actually returns a list of files; maybe it could have its name changed to 'filelisting', and a 'directorylisting' function added ? -- Alex. P.S. Here's my version, called folderListing. NB 1. it is non-recursive - in general iteration is faster than recursion. 2. like Ben's recursive version, it allows for easy suppression of "dot-folders", but I made that a parameter of the function 3. it puts newly found directories at the start of the list, rather than the end, so that it will get exactly the same result (i.e. in the same order) as the straightforward recursive method (i.e. depth-first). Just adding them at the end would have been marginally more efficient, and noticeably simpler in code - but it's a price worth paying for equivalency testing. function folderListing pFolder, pIgnoreDotFolders local tFolders, tAllFolders local tOriginalFolder if pIgnoreDotFolders is empty then -- ignore them by default (Unix convention) put TRUE into pIgnoreDotFolders end if put the defaultfolder into tOriginalFolder local tAbsFolder, tFoldersLeft, tSub, tFoldersHere set the defaultfolder to pFolder put the defaultfolder into tAbsFolder -- changes relative into absolute put CR into tFoldersLeft repeat until tFoldersLeft is empty put line 1 of tFoldersLeft into tSub set the defaultFolder to (tAbsFolder & tSub) if the result is not empty then -- skip or report as needed next repeat end if put (tAbsFolder & tSub) &CR after tAllFolders try put folders() into tFolders end try delete line 1 of tFolders -- delete ".." if pIgnoreDotFolders then filter tFolders without ".*" end if if tFolders is empty then delete line 1 of tFoldersLeft else put empty into tFoldersHere repeat for each line L in tFolders put tSub & "/" & L & CR after tFoldersHere end repeat put char 1 to -2 of tFoldersHere into line 1 of tFoldersLeft end if end repeat set the defaultfolder to tOriginalFolder return tAllFolders end folderListing ___ 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
Re: directory tree -> array
t;> return R >>end if >>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 >>-- delete variable firstPass >>return R >> end directoryListing >> >> function directoryListingToArray pDirectoryList >>put line 1 of pDirectoryList into tRoot >>delete line 1 of pDirectoryList >>set the itemDelimiter to "/" >>put empty into aArrayData [tRoot] >>repeat for each line tPath in pDirectoryList >> replace tRoot with empty in tPath >> put "[" & quote before tPath >> put quote & "]" after tPath >> replace "/" with quote & "]" & space & "[" & quote in tPath >> put "[" & quote & tRoot & quote & "] " before tPath >> put "put empty into aArrayData " & tPath into tCommand >> do tCommand >>end repeat >>return aArrayData >> end directoryListingToArray >> >> Bob S >> >> >>> On Feb 1, 2020, at 13:16 , Dick Kriesel via use-livecode >>> wrote: >>> >>> >>>> On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode >>>> wrote: >>>> >>>> I stumbled across a code challenge for y'all, one that seems seductively >>>> simple but I don't think it is: >>>> >>>> What is the simplest way to build an array that reflects the files and >>>> folders within a given folder? >>>> >>>> There's a discussion about this here: >>>> >>>> https://forums.livecode.com/viewtopic.php?f=7&t=33565 >>>> >>>> >>>> On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode >>>> wrote: >>>> We have many handlers that deliver directory trees as lists, but arrays >>>> are a different beast. Because the depth is both unknowable and varied, I >>>> can't think of a way to do this without resorting to "do". >>> >>> >>> Since that thread vanished last week, and hasn’t returned, I'm offering >>> help here instead. >>> >>> The list of full paths contains enough information to build an array >>> representation of the directory tree. >>> >>> >>> /** >>> >>> Summary: Given a list of full paths, and given the partial path they share, >>> build an array representing the directory structure >>> >>> pPaths: a return-delimited list of full paths >>> >>> pPath: the path that was used to generate the list of full paths >>> >>> Returns (array): A array with a branch node for each folder and a leaf node >>> for each file >>> >>> Description: Eliminate pPath from every line of pPaths. Then insert each >>> line into an array. >>> >>> email subject "directory tree -> array" >>> >>> forum topic "f=7&t=33565" >>> >>> */ >>> >>> >>> function arrayFromPaths pPaths, pPath -- a list of full paths, and the path >>> that was used to generate the list >>> >>> local tPaths, tFile, tArray >>> >>> set the itemDelimiter to "/" >>> >>> >>> put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into >>> tPaths -- eliminate pPath from every full path >>> >>> repeat for each line tPath in tPaths -- insert each file name into the array >>> >>> put the last item of tPath into tFile >>> >>> delete the last item of tPath >>> >>> if tPath is empty then -- the file is in folder pPath >>> >>> put "true" into tArray[ tFile ] >>> >>> else -- the file is in a folder in folder pPath >>> >>> split tPath by slash >>> >>> put "true" into tArray[ tPath ][ tFile ] >>> >>> end if >>> >>> end repeat >>> >>> >>> return tArray >>> >>> end arrayFromPaths >>> >>> >>> on mouseUp >>> >>> local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and >>> folder d, which contains files e and f >>> >>> local tPath = "a/b" -- the shared partial path >>> >>> replace comma with cr in tPaths >>> >>> >>> get arrayFromPaths( tPaths, tPath ) >>> >>> >>> breakpoint >>> >>> end mouseUp >>> >>> >>> >>> >>> If the topic reappears soon, I’ll repost there because reading code is >>> easier there. >>> >>> By, the way, thanks to RG for the bug report on my earlier posting in the >>> now-vanished thread. >>> >>> — Dick >>> >>> >>> >>> ___ >>> 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 ___ 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
Re: directory tree -> array
/forums.livecode.com/viewtopic.php?f=7&t=33565 On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode wrote: We have many handlers that deliver directory trees as lists, but arrays are a different beast. Because the depth is both unknowable and varied, I can't think of a way to do this without resorting to "do". Since that thread vanished last week, and hasn’t returned, I'm offering help here instead. The list of full paths contains enough information to build an array representation of the directory tree. /** Summary: Given a list of full paths, and given the partial path they share, build an array representing the directory structure pPaths: a return-delimited list of full paths pPath: the path that was used to generate the list of full paths Returns (array): A array with a branch node for each folder and a leaf node for each file Description: Eliminate pPath from every line of pPaths. Then insert each line into an array. email subject "directory tree -> array" forum topic "f=7&t=33565" */ function arrayFromPaths pPaths, pPath -- a list of full paths, and the path that was used to generate the list local tPaths, tFile, tArray set the itemDelimiter to "/" put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into tPaths -- eliminate pPath from every full path repeat for each line tPath in tPaths -- insert each file name into the array put the last item of tPath into tFile delete the last item of tPath if tPath is empty then -- the file is in folder pPath put "true" into tArray[ tFile ] else -- the file is in a folder in folder pPath split tPath by slash put "true" into tArray[ tPath ][ tFile ] end if end repeat return tArray end arrayFromPaths on mouseUp local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and folder d, which contains files e and f local tPath = "a/b" -- the shared partial path replace comma with cr in tPaths get arrayFromPaths( tPaths, tPath ) breakpoint end mouseUp If the topic reappears soon, I’ll repost there because reading code is easier there. By, the way, thanks to RG for the bug report on my earlier posting in the now-vanished thread. — Dick ___ 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
Re: directory tree -> array
Hey Bob, there's a problem in directoryListingToArray in some cases. Wen I run it on my home directory, I get an error message ...: execution error at line 119 (repeat: error in statement), char 1 The 'repeat' error is misleading - that's just the line following the 'do tCommand'. It's caused because I have a file (I think created by Dropbox - but I'm not sure) which contains a control character (specifically, numtochar(13)) in its name. (it urlencodes to .../Dropbox/Icon%0D) When this gets to your "do" command, it causes Livecode to stop with an error report, because the embedded "CR" gets the parser confused. You can 'fix' it by adding replace numtochar(13) with "%0D" in tPath at the appropriate place - but it's not clear if that's just storing up problems for the future. (Just another reason to avoid 'do', and go with Ben's recursive solution straight into an array rather than getting a list and converting it. But if you do have a reason to convert a list, then you could come up with a way to do that without 'do' using a similar method to Ben's) Alex. On 03/02/2020 17:19, Bob Sneidar via use-livecode wrote: I already wrote some functions to do this but sent them to Richard in a demo stack. Here is the code based on directoryListing, which I believe is in the MasterLibrary. I made a minor adjustment to it if I recall. DirectoryListing was returning duplicate paths for each unique folder for some reason. I modified it to only return one unique path for a given folder. Setting the arrayData of a tree widget to the returned value of directoryListingToArray() function will yield the results you want. ... function directoryListingToArray pDirectoryList put line 1 of pDirectoryList into tRoot delete line 1 of pDirectoryList set the itemDelimiter to "/" put empty into aArrayData [tRoot] repeat for each line tPath in pDirectoryList replace tRoot with empty in tPath put "[" & quote before tPath put quote & "]" after tPath replace "/" with quote & "]" & space & "[" & quote in tPath put "[" & quote & tRoot & quote & "] " before tPath put "put empty into aArrayData " & tPath into tCommand do tCommand end repeat return aArrayData end directoryListingToArray Bob S On Feb 1, 2020, at 13:16 , Dick Kriesel via use-livecode wrote: On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode wrote: I stumbled across a code challenge for y'all, one that seems seductively simple but I don't think it is: What is the simplest way to build an array that reflects the files and folders within a given folder? There's a discussion about this here: https://forums.livecode.com/viewtopic.php?f=7&t=33565 On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode wrote: We have many handlers that deliver directory trees as lists, but arrays are a different beast. Because the depth is both unknowable and varied, I can't think of a way to do this without resorting to "do". Since that thread vanished last week, and hasn’t returned, I'm offering help here instead. The list of full paths contains enough information to build an array representation of the directory tree. /** Summary: Given a list of full paths, and given the partial path they share, build an array representing the directory structure pPaths: a return-delimited list of full paths pPath: the path that was used to generate the list of full paths Returns (array): A array with a branch node for each folder and a leaf node for each file Description: Eliminate pPath from every line of pPaths. Then insert each line into an array. email subject "directory tree -> array" forum topic "f=7&t=33565" */ function arrayFromPaths pPaths, pPath -- a list of full paths, and the path that was used to generate the list local tPaths, tFile, tArray set the itemDelimiter to "/" put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into tPaths -- eliminate pPath from every full path repeat for each line tPath in tPaths -- insert each file name into the array put the last item of tPath into tFile delete the last item of tPath if tPath is empty then -- the file is in folder pPath put "true" into tArray[ tFile ] else -- the file is in a folder in folder pPath split tPath by slash put "true" into tArray[ tPath ][ tFile ] end if end repeat return tArray end arrayFromPaths on mouseUp local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and folder d, which contains files e and f local tPath = "a/b"
Re: directory tree -> array
Yes, but I couldn't get the recursion working right. My brain fried. Bob S > On Feb 3, 2020, at 11:18 , Ben Rubinstein via use-livecode > wrote: > > On 22/01/2020 18:26, Richard Gaskin via use-livecode wrote: >> We have many handlers that deliver directory trees as lists, but arrays are >> a different beast. Because the depth is both unknowable and varied, I can't >> think of a way to do this without resorting to "do". > > Surely this is what recursion does for you? > > e.g. > > function directoryTreeAsArray tRoot, tSubPath --> aTree > local aTree > set the defaultFolder to tRoot & "/" & tSubPath > put the files into aTree["files"] > repeat for each line f in the folders > if char 1 of f = "." then next repeat -- unix gotcha > put directoryTreeAsArray(tRoot, tSubPath & "/" & f) into > aTree["folders"][f] > end repeat > return aTree > end directoryTreeAsArray > > (initially invoked with empty second parameter) > > Or have I misunderstood the requirement? ___ 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
Re: directory tree -> array
On 22/01/2020 18:26, Richard Gaskin via use-livecode wrote: We have many handlers that deliver directory trees as lists, but arrays are a different beast. Because the depth is both unknowable and varied, I can't think of a way to do this without resorting to "do". Surely this is what recursion does for you? e.g. function directoryTreeAsArray tRoot, tSubPath --> aTree local aTree set the defaultFolder to tRoot & "/" & tSubPath put the files into aTree["files"] repeat for each line f in the folders if char 1 of f = "." then next repeat -- unix gotcha put directoryTreeAsArray(tRoot, tSubPath & "/" & f) into aTree["folders"][f] end repeat return aTree end directoryTreeAsArray (initially invoked with empty second parameter) Or have I misunderstood the requirement? ___ 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
Re: directory tree -> array
I already wrote some functions to do this but sent them to Richard in a demo stack. Here is the code based on directoryListing, which I believe is in the MasterLibrary. I made a minor adjustment to it if I recall. DirectoryListing was returning duplicate paths for each unique folder for some reason. I modified it to only return one unique path for a given folder. Setting the arrayData of a tree widget to the returned value of directoryListingToArray() function will yield the results you want. function directoryListing whatFolder, c /* Example: put 1 into cNum if target = empty then answer folder "Pick a folder you want to walk:" put it into whatFolder set cursor to watch put directoryListing(whatFolder,cNum) 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 and the commandKey is down then put word 2 of the clickline into tLine put line tLine of target into tLaunch launch document tLaunch 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,cNum) 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,cNum) into target global firstPass if firstPass is empty then put whatFolder & cr into R put false into firstPass end if */ set the directory to whatFolder if c = 0 or the result is not empty then -- delete variable firstPass return R end if 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 -- delete variable firstPass return R end directoryListing function directoryListingToArray pDirectoryList put line 1 of pDirectoryList into tRoot delete line 1 of pDirectoryList set the itemDelimiter to "/" put empty into aArrayData [tRoot] repeat for each line tPath in pDirectoryList replace tRoot with empty in tPath put "[" & quote before tPath put quote & "]" after tPath replace "/" with quote & "]" & space & "[" & quote in tPath put "[" & quote & tRoot & quote & "] " before tPath put "put empty into aArrayData " & tPath into tCommand do tCommand end repeat return aArrayData end directoryListingToArray Bob S > On Feb 1, 2020, at 13:16 , Dick Kriesel via use-livecode > wrote: > > >> On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode >> wrote: >> >> I stumbled across a code challenge for y'all, one that seems seductively >> simple but I don't think it is: >> >> What is the simplest way to build an array that reflects the files and >> folders within a given folder? >> >> There's a discussion about this here: >> >> https://forums.livecode.com/viewtopic.php?f=7&t=33565 >> >> >> On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode >> wrote: > >> >> We have many handlers that deliver directory trees as lists, but arrays are >> a different beast. Because the depth is both unknowable and varied, I can't >> think of a way to do this without resorting to "do". > > > > Since that thread vanished last week, and hasn’t returned, I'm offering help > here instead. > > The list of full paths contains enough information to build an array > representation of the directory tree. > > > /** > > Summary: Given a list of full paths, and given the partial path they share, > build an array representing the directory structure > > pPaths: a return-delimited list of full paths > > pPath: the path that was used to generate the list of full paths > > Returns (array): A array
Re: directory tree -> array
> On Jan 22, 2020, at 10:17 AM, Richard Gaskin via use-livecode > wrote: > > I stumbled across a code challenge for y'all, one that seems seductively > simple but I don't think it is: > > What is the simplest way to build an array that reflects the files and > folders within a given folder? > > There's a discussion about this here: > > https://forums.livecode.com/viewtopic.php?f=7&t=33565 > > > On Jan 22, 2020, at 10:26 AM, Richard Gaskin via use-livecode > wrote: > > We have many handlers that deliver directory trees as lists, but arrays are a > different beast. Because the depth is both unknowable and varied, I can't > think of a way to do this without resorting to "do". Since that thread vanished last week, and hasn’t returned, I'm offering help here instead. The list of full paths contains enough information to build an array representation of the directory tree. /** Summary: Given a list of full paths, and given the partial path they share, build an array representing the directory structure pPaths: a return-delimited list of full paths pPath: the path that was used to generate the list of full paths Returns (array): A array with a branch node for each folder and a leaf node for each file Description: Eliminate pPath from every line of pPaths. Then insert each line into an array. email subject "directory tree -> array" forum topic "f=7&t=33565" */ function arrayFromPaths pPaths, pPath -- a list of full paths, and the path that was used to generate the list local tPaths, tFile, tArray set the itemDelimiter to "/" put char 2 to -1 of replaceText( cr & pPaths, cr & pPath & slash, cr ) into tPaths -- eliminate pPath from every full path repeat for each line tPath in tPaths -- insert each file name into the array put the last item of tPath into tFile delete the last item of tPath if tPath is empty then -- the file is in folder pPath put "true" into tArray[ tFile ] else -- the file is in a folder in folder pPath split tPath by slash put "true" into tArray[ tPath ][ tFile ] end if end repeat return tArray end arrayFromPaths on mouseUp local tPaths = "a/b/c,a/b/d/e,a/b/d/f" -- folder a/b contains file c and folder d, which contains files e and f local tPath = "a/b" -- the shared partial path replace comma with cr in tPaths get arrayFromPaths( tPaths, tPath ) breakpoint end mouseUp If the topic reappears soon, I’ll repost there because reading code is easier there. By, the way, thanks to RG for the bug report on my earlier posting in the now-vanished thread. — Dick ___ 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
Re: directory tree -> array
Wasn’t talking about the widget but building the underlying array that it would display. Thanks, Brian On Jan 22, 2020, 2:21 PM -0500, Richard Gaskin via use-livecode , wrote: > Where is the tree widget used in the Standalone Builder? > > -- > Richard Gaskin > Fourth World Systems > > Brian Milby wrote: > > > Much of the needed work is already done in the standalone builder > > code. I don’t think it does a nested array, but it does handle things > > like processing links/shortcuts. I’ll try to take a look to see if a > > short recursive function could be easily built. > > > > Thanks, > > Brian > > On Jan 22, 2020, 1:59 PM -0500, Richard Gaskin wrote: > > > Bob Sneidar wrote: > > > > > > > I found a populate directory demo with a tree widget, but it fails, > > > > almost certainly because the embedded widget is out of sync with > > > > the current tree widget. Here you go. > > > > > > If you turn one up it would be good to see the code. > > > > > > So widgets can embed other widgets? I did not know that. Does that > > > use a reference, or a copy? > > > -- > > > Richard Gaskin > > > Fourth World Systems > > > ___ > 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
Re: directory tree -> array
Where is the tree widget used in the Standalone Builder? -- Richard Gaskin Fourth World Systems Brian Milby wrote: > Much of the needed work is already done in the standalone builder > code. I don’t think it does a nested array, but it does handle things > like processing links/shortcuts. I’ll try to take a look to see if a > short recursive function could be easily built. > > Thanks, > Brian > On Jan 22, 2020, 1:59 PM -0500, Richard Gaskin wrote: >> Bob Sneidar wrote: >> >> > I found a populate directory demo with a tree widget, but it fails, >> > almost certainly because the embedded widget is out of sync with >> > the current tree widget. Here you go. >> >> If you turn one up it would be good to see the code. >> >> So widgets can embed other widgets? I did not know that. Does that >> use a reference, or a copy? >> -- >> Richard Gaskin >> Fourth World Systems ___ 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
Re: directory tree -> array
Much of the needed work is already done in the standalone builder code. I don’t think it does a nested array, but it does handle things like processing links/shortcuts. I’ll try to take a look to see if a short recursive function could be easily built. Thanks, Brian On Jan 22, 2020, 1:59 PM -0500, Richard Gaskin via use-livecode , wrote: > Bob Sneidar wrote: > > > I found a populate directory demo with a tree widget, but it fails, > > almost certainly because the embedded widget is out of sync with > > the current tree widget. Here you go. > > If you turn one up it would be good to see the code. > > So widgets can embed other widgets? I did not know that. Does that use > a reference, or a copy? > > -- > Richard Gaskin > Fourth World Systems > Software Design and Development for the Desktop, Mobile, and the Web > > ambassa...@fourthworld.com http://www.FourthWorld.com > > ___ > 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
Re: directory tree -> array
Bob Sneidar wrote: > I found a populate directory demo with a tree widget, but it fails, > almost certainly because the embedded widget is out of sync with > the current tree widget. Here you go. If you turn one up it would be good to see the code. So widgets can embed other widgets? I did not know that. Does that use a reference, or a copy? -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ 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
Re: directory tree -> array
Won't work. The behavior is missing. Bob S > On Jan 22, 2020, at 10:38 , Bob Sneidar via use-livecode > wrote: > > I found a populate directory demo with a tree widget, but it fails, almost > certainly because the embedded widget is out of sync with the current tree > widget. Here you go. > > > >> On Jan 22, 2020, at 10:34 , Bob Sneidar via use-livecode >> wrote: >> >> The tree view widget has an array at it's core. I seem to remember someone >> creating a stack that uses the tree view widget to represent a folder >> structure. You should be able to simply extract the array from that. I'll >> poke around. >> >> Bob S > > ___ > 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
Re: directory tree -> array
I found a populate directory demo with a tree widget, but it fails, almost certainly because the embedded widget is out of sync with the current tree widget. Here you go. > On Jan 22, 2020, at 10:34 , Bob Sneidar via use-livecode > wrote: > > The tree view widget has an array at it's core. I seem to remember someone > creating a stack that uses the tree view widget to represent a folder > structure. You should be able to simply extract the array from that. I'll > poke around. > > Bob S ___ 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
Re: directory tree -> array
The tree view widget has an array at it's core. I seem to remember someone creating a stack that uses the tree view widget to represent a folder structure. You should be able to simply extract the array from that. I'll poke around. Bob S > On Jan 22, 2020, at 10:21 , Bob Sneidar via use-livecode > wrote: > > I thought someone created a handler for this? It requires iteration. > > Bob S > > >> On Jan 22, 2020, at 10:17 , Richard Gaskin via use-livecode >> wrote: >> >> I stumbled across a code challenge for y'all, one that seems seductively >> simple but I don't think it is: >> >> What is the simplest way to build an array that reflects the files and >> folders within a given folder? >> >> There's a discussion about this here: >> >> https://forums.livecode.com/viewtopic.php?f=7&t=33565 >> >> -- >> Richard Gaskin > > > ___ > 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
Re: directory tree -> array
We have many handlers that deliver directory trees as lists, but arrays are a different beast. Because the depth is both unknowable and varied, I can't think of a way to do this without resorting to "do". -- Richard Gaskin Bob Sneidar wrote: > I thought someone created a handler for this? It requires iteration. > > On Jan 22, 2020, at 10:17 , Richard Gaskin wrote: > > I stumbled across a code challenge for y'all, one that seems > seductively simple but I don't think it is: > > What is the simplest way to build an array that reflects the files > and folders within a given folder? > > There's a discussion about this here: > > https://forums.livecode.com/viewtopic.php?f=7&t=33565 ___ 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
Re: directory tree -> array
I thought someone created a handler for this? It requires iteration. Bob S > On Jan 22, 2020, at 10:17 , Richard Gaskin via use-livecode > wrote: > > I stumbled across a code challenge for y'all, one that seems seductively > simple but I don't think it is: > > What is the simplest way to build an array that reflects the files and > folders within a given folder? > > There's a discussion about this here: > > https://forums.livecode.com/viewtopic.php?f=7&t=33565 > > -- > Richard Gaskin ___ 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
directory tree -> array
I stumbled across a code challenge for y'all, one that seems seductively simple but I don't think it is: What is the simplest way to build an array that reflects the files and folders within a given folder? There's a discussion about this here: https://forums.livecode.com/viewtopic.php?f=7&t=33565 -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ 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