Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive Remove Directory
Message
From
10/12/1999 17:23:30
 
 
To
10/12/1999 16:50:32
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvania, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00302015
Message ID:
00302032
Views:
27
>semi-follow up to the MD issue
>
>I need to remove a root directory, which may contain subdirectories. Recursion seemed the simplest solution:
>1. Delete the files
>2. Remove the subdirectories
>3. Remove the root directory
>
>FUNCTION RemoveDirectory
>Parameters dirpath
> Dele file (dirpath+"*.*")
> entries = adir(aRemDirs,dirpath+"*.*","D")
> If entries >= 0
> for i = 1 to entries
> If !Inlist(aRemDirs(i,1),".","..")
> RemoveDirectory(dirpath+aRemDirs(i,1)+"\")
> Endif
> Next
> Endif
> RD (dirpath)
>Return && RemoveDirectory
>
>I read in the help that functions' parameters are passed by value, and i THOUGHT this would protect the scoping necessary for recursion. It's late on a friday, and while i can see this isn't working, i can't seem to figure out why.
>
>I'm hoping someone will immediately see what i'm doing wrong. TIA

Without looking at it too closely, in recursive routines I find it a lot easier to make sure I'm always working with local variables. I would use LPARAMETERS instead of PARAMETERS, declare variables and arrays LOCAL, etc.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform