Hi Sylvain,
This came up the other day in the ExamStudyGroup in the wiki. The problem is FOR EACH walks through the collection 1 form at a time. As each object is destroyed, the remaining objects move up 1 place in the collection. When it gets half way through the collection all the forms in the last half are now in the front half (I think the effect is that it skips every other one).
I think Craig pointed it out, Mike came up with the solution, I didn't believe it, Nancy tested it, and then Nancy hit me with a fish. :)
Better would be:
** Note we will use nFormIndex to move ahead in the collection
** if a form can't be relased.
nFormIndex = 1
For x = 1 to _screen.FormCount
oForm = _screen.Forms[ nFormIndex ]
IF oForm.QueryUnload()
oForm.Release()
else
nFormIndex = nFormIndex + 1
ENDIF
endfor
Hope this helps.
>
FOR EACH oForm IN _Screen.Forms
> IF oForm.QueryUnload()
> oForm.Release()
> ENDIF
>ENDFOR
HTH
>Can someone tell me how to close all the running form in the app. enviroment.
Roi
'MCP' Visual FoxPro
In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!