Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
For each doesn't release all forms?
Message
From
18/07/2007 10:08:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01241310
Message ID:
01241507
Views:
48
This message has been marked as a message which has helped to the initial question of the thread.
>>>>Naomi,
>>>>
>>>>Usually you can not iterate with FOR EACH in any collection while adding or removing items. Your Step - 1 solution is correct, IMO
>>>
>>>Hmm, I'm not sure, this needs to be comfirmed. I thought "for each" should work even when adding or removing. I need to review my own FAQ again, I already switched to George's solution but it didn't help yet.
>>>
>>
>>I can confirm if you care:) Do not add/remove with a foreach (not in VFP, not in .Net - at least documented for .Net:)
>>Cetin
>
>I do, Cetin.
>
>Yes, now I can see that we can not use collection. I also need to re-check my FAQ.
>
>But for some reason even
>
>lnForms = _SCREEN.FORMCOUNT
>
>		DO WHILE lnForms > 0 AND llExit
>			IF PEMSTATUS(_SCREEN.FORMS(lnForms),'QueryUnload', 5)
>				llExit = _SCREEN.FORMS(lnForms).QUERYUNLOAD()
>			ENDIF
>			IF llExit
>				_SCREEN.FORMS(lnForms).RELEASE
>				lnForms = m.lnForms - 1
>			ENDIF
>		ENDDO
>
>
>Didn't work yesterday. Do you know what may be wrong?
>
>Appreciate your response in advance.

I can see a series of reasons with this piece of code but unlikely you'd be trapped with some of them:
1) mdot, mdot please mdot.
2) lnForms = m.lnForms - 1 is suspicious code. What if there is one or more toolbars associated with a form or one is 'child' of another and released due its parent is released (ie: name linked).

lnForms = _screen.formcount

sounds better.

3) No guarantee that you could release a form like this. ie: what if one is waiting for a response, hanging object ref., valid etc.
4) forms are not guaranteed to be members of _screen, no check on _vfp.
5) I don't know:)
I'd instead use oApp's form collection and form manager (hope you have one such form manager).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform