Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:13 22 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Recursive Search MMBASIC

Author Message
Yourock17
Newbie

Joined: 09/01/2015
Location: Australia
Posts: 12
Posted: 10:34pm 02 Nov 2016
Copy link to clipboard 
Print this post


I was wondering if anybody has made/come up with a solution for Recursive directory search in MMBASIC for the Colour Maximite. I have attempted programming one but it doesn't output all of the files in the drive, just the first couple of files.

This is my attempt at one:
Do 'Go to root of drive
If Cwd$ <> "B:\" Then Chdir ".."
Loop Until Cwd$ = "B:\"
Dim DirVisited$(120) 'Define Directories Visited
''''''''''''''''''
'Count Files On B:
''''''''''''''''''
Print CLR$(2) Cwd$, CLR$(5) Directory$
Directory$ = Dir$("*.*", DIR)
1 Do
Count = Count+1 'Assign a number to a directory
If Directory$ <> "" Then 'If no sub directories then
If Directory$ = "." Then Directory$ = Dir$() 'Skip this
If Directory$ = ".." Then Directory$ = Dir$() 'and this
For Num = 1 To 120
If Directory$ = DirVisited$(Num) Then Directory$ = Dir$()
Next
Chdir Directory$ 'Change
Print CLR$(2) Cwd$, CLR$(5) Directory$
DirVisited$(Count) = Directory$
Else
Chdir ".."
EndIf
Directory$ = Dir$()
Loop Until Cwd$ = "B:\" And Directory$ = ""


And this is it's Output (all directories in root sadly):

B:\
B:\PROGRAMS PROGRAMS
B:\RECOVERY RECOVERY
B:\SETTINGS SETTINGS
B:\USER USER
B:\WINDOWS WINDOWS


I would be very very happy, I have been trying at this one since around June.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4381
Posted: 10:42pm 02 Nov 2016
Copy link to clipboard 
Print this post

Maybe someone already posted something?

I'm not quite sure what your plan for Cwd$ was but it looks not to have happened.

If you want to do a recursive listing I suggest recursive code because unrolling via a loop is faster but tougher to code (can be much tougher).

JohnEdited by JohnS 2016-11-04
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1772
Posted: 12:32am 03 Nov 2016
Copy link to clipboard 
Print this post

My solution (not for a recursive search, sorry!).

(See sub ReadDir)

regards
MichaelEdited by twofingers 2016-11-05
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026