Just one minor thing, you can avoid using RUN RD here, as VFP has RD or RMDIR as native command.
As you also use MD to create the temp folder, you can use RD in the same manner to delete it later.
Besides that PARAMETERS vs LPARAMETERS creates private variables for the parameters, so that would also be sufficient to stop the previous private variables with same name to "bleed in". Anyway, it's better to have local only variables per recursion level, so just use LPARAMETERS and no PRIVATE vars. Creating private variables only makes sense, if you want them to be accessible in multiple stack/recursion levels
without needing to pass them on: see here:
Code:
RELEASE ALL EXTENDED
* creating a private variable
pCountCalls = 0
Recurse(0)
PROCEDURE Recurse()
PARAMETERS pPara1
pCountCalls = pCountCalls + 1
? AStackInfo(laDummy)-1, pCountCalls, pPara1
If pPara1<5
Recurse(pPara1+1)
? "returned from call:", pCountCalls, pPara1
ENDIF
The stack level builds up (and pCountCall reflects the same number as atackinfo rows), then when pPara reaches 5 there is no further Recurse call and the stack is reduced, the second ? command shows pPara1 at each stack level did not change and so the values go back to 4,3,2,1,0, as they were before calling, though there is no PRIVATE pPara1, only PARAMETERS pPara1.
The private variable pCountCalls created before the initial Recurse call is staying at the count level, it is also never again "declared", it is used as a public variable never needed to pass on, because that's what private variables really are.
And why did I put declared in quotes? Private variables are resulting from NOT being declared, PRIVATE is not a declaration command, it rather ends the scope of a previous variable of same name. If it would be a declaration command creating variables in the manner LOCAL does, you wouldn't have PRIVATE ALL LIKE p*, this is just defining some kind of namespace of variables that should not bleed in and therefore be available to this method/procedure to create new variables with these names or name patterns. Put in a PRIVATE pCountCalls and the line pCountCalls = pCountCalls + 1 will fail, as that mainly only undeclares the pCountCalls variables previoulsy created and initialized to 0.
So in short, in this code both pCountCalls and pPara are private, but the scope of pCountCalls is all code including recursive calls, while each Recursion() procedure recreates a pPara1 variable and so each recursion level hads its own "private" local pPara1. PARAMETERS unlike PRIVATE does not only end the scope of an eventually previously existing private variable of same name, it also then directly set the new private variable to the passed in value.
Bye, Olaf.