Directory() does not include sub directories

Hi and happy new year to all of you!

Using Clarion 11.1 under Windows 11 I try to build a picture database.

The following code is copied from the documentation and only merely modified:

    PicPath = 'C:\Users\Volke\Dropbox\Portrait'
    setpath(longpath(PicPath))	
    DIRECTORY(AllFiles,'*.*',ff_:DIRECTORY)   !Get all files and directories
    Recs = RECORDS(AllFiles)  
    LOOP LP = Recs TO 1 BY -1
       GET(AllFiles,LP)
       IF BAND(FIL:Attrib,ff_:DIRECTORY) AND FIL:ShortName <> '..' AND FIL:ShortName <> '.' 
             PICTURES:Name           = FIL:Name
             PICTURES:Filename       = longpath(FIL:Name)
             get(pictures,0)	
    		 if ~duplicate(pictures) then add(pictures).
    		 brw6.ResetSort(1)
    		 brw6.UpdateWindow()	
      CYCLE                                   !Let sub-directory entries stay
     ELSE
      DELETE(AllFiles)                        !Get rid of all other entries
     END !IF
    END !LOOP
    setpath(longpath(ProgramPath))	

It only searches in ‘C:\Users\Volke\Dropbox\Portrait’ but it does not enter the sub-directories.
In the DIRECTORY()-command I also tried ff_:NORMAL and ff_:NORMAL+ff_:DIRECTORY.

Where’s the mistake?

Thank you and kind regards,

Volker

Have you seen these, there might be some clues in these threads?

Win10 C6 Directory() 8min 40 secs, C11 Directory() 31mins 47 seconds - ClarionHub

DosFileLookup in Directory mode does not select Default Directory - ClarionHub

Using DIRECTORY with ff_:queue crashes with Remote Desktop Service and User Profile Disks - questions / tips - ClarionHub

Attached program lists names of both normal files and sub-directories.
test.clw (3.0 KB)

Dear RichClaCode,

Of course I searched Clarion Hub before I asked. But I cannot find any help in the given examples.
DIRECTORY() works so far, except that it doesn’t work recursively. I doesn’t look into the directories.
It only works in the “top level”.

Kind regards,

Volker

Hi Also,

I cannot get this example to run. I am not familiar to compile .clw-files i/o .app-files.

Kind regards,

Volker

Time to learn something new?

Always… :smiley:

But is there any documentation to do this? I searcheds the Clarion help for “Compile” and “clw” but did not find anything helpful.

For me, the command-line make utility and so-called “legacy” PRJ projects are far better.
Dir.zip (2.3 KB)

Well, thank you.

Obviously I made everything correct because I got exactly the same error messages:

It seems that browses do not work with ‘hand coded’ queues.

Also the “dir” in the AdjustDir-procedure is unknown.

Well. My main problem is still the Directory()-command. It works, but only in the top level directory (as defined in PicPath). But it should work recursively (looking also into the sub directories). Years ago (with Clarion 8) I got it to work but I don’t have the application anymore.

Kind regards,

Volker

Open the solution from my previous message and just build it by pressing F8.

If you want to edit the source file, open the Solution Explorer toolbox, highlight the filename under the project, press right mouse button and choose the Open item in the menu.

Hi Also,

Thank you. At least I could get this to work.

In your example I make a double click onto directories. This always triggers a new directory() call. That’s not exactly what I want. I want to get every picture file calling directory() only once regardless in which level the picture is to be found. As far as I remember, directory() worked recursively - at least under Clarion 8.

Example

Kind regards,

Volker

Directory never worked recursively.

My example just shows how to handle sub-directories.

No, DIRECTORY works for one folder only and not seeks for files in sub-folders.

This GitHub example shows a recursive directory load to a queue in a function. Also displays in a LIST, both 1 level and a tree.

1 Like

Sorry I missed this link but it is the top link in the results for the search term “folder recursion”
How to call SHFileOperation API to recursively delete files and folders - questions - ClarionHub

You also dont say what Tree Traversal method you want to use.
Tree traversal - Wikipedia

I had written some code somewhere which let me choose what tree traversal methods to use, I’ll see if I can find it later on tonight, I dont think its in a class though, but it might have been some of the code that got wiped from my machine when it got hacked, so if I can find it, I’ll post it.

Edit. I’ve just seen above @CarlBarnes has posted some working code, so that should get you going.

Hi Carl,

Thank you so much! After watching the Screenshots this is exactly what I looked for. Even more, because the tree would have been my next problem. I will test it next weekend.

Thank you again.

Volker

Hi RichClaCode,

I read the Wikipedia article. Then I read it in German. And then I decided that my programming skills are not sufficient at all. Well, it‘s only a hobby.
After years of professional photography, I just have a large photo collection now and want to bring it into some order.

I am rather confident that Carl‘s example will help.

Kind regards,

Volker

Hi Also,

That is strange as I once wrote a running program. Well, maybe I had a good example. Thank you!

Kind regards, Volker

Here is just another example of Directory usage, very similar to example posted by Also
key points:
-just 60 lines of codes (to highlight built-in Clarion RTL features)
-drill up/down through directories with mouse or keyboard
-resizable window
-code compatible with older versions (tested also in c55)
DirBrowser.zip (2,0 KB)

1 Like