Hi, yeah this can be a bit tricky, Try this. You will need buddy API though.



Set a global to hold the list data, and then send this and the path you want
to drill down from i.e.

global gMasterFolderList, gAddFiles

on startmovie

gMasterFolderList = [:]

gAddFiles = 0 -- you can set this to 1 to include files as well as folders

buildFolderFileList (gMasterFolderList,the pathname)

end



---Then say in a exitframe wait until it has finished its recursion.

on exitFrame me

if gMasterFolderList = [:] then

go to the frame

else

go to the frame +1

end



--This is the main function

on buildFolderFileList (fileList, path)


  if path = VOID then path = the moviepath
  if char length(path) of path <> gDelimiter then path = path &
gDelimiter -- add a delimiter if the pathname doesn't contain one


  ----
-- Get list of files in current folder
  ----


repeat with i = 1 to the maxinteger


    FileorFolder = getNthFileNameInFolder (path, i) -- use the
getNthFileNameInFolder since this returns both files and folders
    if FileorFolder = EMPTY then exit repeat -- if no folder or file then
exit this recursion

    ----
    -- Check for subfolders and drill down
    ----

    if baFolderExists( path & FileorFolder & gDelimiter) then


      ---
      if integerP(value(FileorFolder.word[1].char[1])) and FileorFolder
contains gDelimiter = FALSE then -- check for malformed or "hidden folders"
        ---

        fileList.addProp(FileorFolder, [:])  --- add the folder as a
property list into the masterlist
        buildFolderFileList (fileList[FileorFolder], path & FileorFolder &
gDelimiter ) -- use the position to send the correct list and path back
recursivly

      else

        put FileorFolder && "invalid or hidden folder" --debug

      end if

    else

    ----
      -- if add files switch (gAddFiles) is switched on all files will also
be added to the list

       if gAddFiles then fileList.addProp(FileorFolder, [:]) --just a empty
prop is added but this could be used for additional data

end if

end repeat


end



Hope this helps.



Rik Green





----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 01, 2002 7:52 PM
Subject: <lingo-l> recursive directory function


>
> Hey - trying to build this myself as elegant/sneaky as I can but running
> into some problems.
>
> Basically I want to build up directory/subdirectory/subsub... contents in
> nested proplists, ie:
>
> ["topdir":["subfolder":["subfolder": []]]
>
> Can anyone point out something like this? I could build it up based on
> user clicks to the top direcotry (ie Zav's d-o.com NeXT browser article)
> but I really would like the full listings at the beginning...
>
> [To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is
for learning and helping with programming Lingo.  Thanks!]

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to