The answer is, "No, DIR$ "by itself" will not work recursively."
That's why the Findfile code to which which you were referred uses a restore of the DTA.
MCM
Announcement
Collapse
No announcement yet.
dir$ and recursion
Collapse
X
-
When you are composing / editing a message Click on *UBB Code is ON
on the left and have a look at the various options.
In your case, using the CODE.../CODE tags enclosed in square brackets,
will preserve your formatting:
Code:FUNCTION foo( d$ ) chdir d$ file$=dir$("*.x", 55) do if file$="" then exit loop if attrib(file$)=16 then foo file$ else print file$ end if file$ = dir$ loop chdir ".." END FUNCTION
[This message has been edited by OTTO WIPFEL (edited May 09, 2002).]
Leave a comment:
-
Guest repliedDavid,
You should have a look at the FINDFILE.BAS example that comes with PB35.
It does what you are looking for, the trick is to save/restore the DTA (Disk Transfer Area) to allow recursive directory scan.
I hope it will help.
------------------
Julien Tosoni - Financial Systems Analyst @ Goodyear France
Leave a comment:
-
dir$ and recursion
Does dir$ work with recursive functions? as in,
if you want to recursively go through all directories
under a subdirectory. Something like:
FUNCTION foo( d$ )
chdir d$
file$=dir$("*.x", 55)
do
if file$="" then exit loop
if attrib(file$)=16 then
foo file$
else
print file$
end if
file$ = dir$
loop
chdir ".."
END FUNCTION
[ this code was formatted, I'm not sure how to preserve it in
the post though. it apparantly ignores leading spaces. ]
The problem that I'm having is that it'll get n levels deep but
as it comes back out it won't find anything. So, in a case where
I have the following directories:
c:\
|----c:\dir1
.....|--c:\dir1\subdir1
.....|--c:\dir1\subdir2
|----c:\dir2
it'll never make it to c:\dir1\subdir2 or c:\dir2.
Please note that I just wrote this code on the fly to illustrate
my question, so since I know that it's buggy, inefficient, and not
elegant, please don't flame me.
------------------
[This message has been edited by David J Venable (edited May 08, 2002).]Tags: None
Leave a comment: