How to pull data from files in multiple folders

I am currently working on a program that uses nested loops to search through all projects and folders and pull data from any formal file it finds.

So far I have been capable of pulling all the names of the files and folders but the only files I can access the data in are those in the lowest level folder I had manually opened before running the program.

As of right now I'm using the read function on the file and then pulling baseline data.

Am I just missing something that will actually make the file its searching open?

Attached is a sample of my loop structure.

Thanks,

Josh


J.Gar - Tue May 26 07:55:26 EDT 2015

Re: How to pull data from files in multiple folders
llandale - Wed May 27 20:05:02 EDT 2015

I cannot find my example, but you need a recursive function like this scribbling:

void RecurseFolder(Folder in_fld)
{   // Deal with all modules in this folder and below
 // RECURSION ENABLED
   Skip skpItems   // KEY 'string' baseName, DATA: 'Item'
   Item itm
   string NameFull
   Folder fldSub

   if (null in_fld)  then return
  // Skip list lets us retrieve items in Alpha order
   skpItems = createString()
   for itm in in_fld do
   {  put(skpItems, name(itm), itm)
   }

  // [1] Deal with modules directly in this folder
   for itm in skpItems do
   {  if (type(itm) != "Formal")  then continue  // ignore folders in this loop
      NameFull = fullName(itm)
      mod = read(NameFull, false, true)
      DealWithModule(mod)    // <<-- you write this function
      close(mod)
   }
  // [2] recurse though sub-folders
   for itm in skpItems do
   {  if (type(itm) != "Folder" and type(itm) != "Project") then continue   // ignore modules
      fldSub = folder(fullName(itm))
      RecurseFolder(fldSub)    // <<-- RECURSION HERE
   }
   delete(skpItems)
}  // end RecurseFolder()

-Louie

Edited: !folder AND !Project; instead of "or"

Re: How to pull data from files in multiple folders
llandale - Wed May 27 20:07:27 EDT 2015

Oh yes.  Don't call them "files".  Sheesh.  They are "Modules".  calling them "files" will let you get confused and think DOORS is like Windows Explorer.