![]() |
Forum Index : Microcontroller and PC projects : Recursive Search MMBASIC
Author | Message | ||||
Yourock17 Newbie ![]() Joined: 09/01/2015 Location: AustraliaPosts: 12 |
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 KingdomPosts: 4036 |
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). John |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1573 |
My solution (not for a recursive search, sorry!). (See sub ReadDir) regards Michael causality ≠ correlation ≠ coincidence |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |