Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
On shutdown problem
Message
 
To
03/03/1998 20:41:36
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00082315
Message ID:
00082402
Views:
38
>>>I have a large app, many forms/formsets, though only some open at any one time. I have a cleanup prg which runs on shutdown. All is fine except when a there are some unsaved edits in the buffer, and the user closes via the main vfp window (X, icon, menu).
>>>
>>>Then I get errors from the buffering, because the shutdown/cleanup runs before the queryunload. What's a good way to deal with this?
>>
>>Bruce, I think you should have something like this code in your shutdown procedure:
>>
local lnForm, loForm
>>
>>for lnForm = _screen.formcount to 1 step - 1
>>	if type("_screen.Forms[lnForm]")=="O" and !isnull(_screen.forms[lnForm])
>>		if !(upper(_screen.forms[lnForm].class) $ "cTOOLBAR;MEMO;GENERAL")
>>		    if pemstatus(_screen.forms[lnForm],'QueryUnload',5)
>>				if _screen.forms[lnForm].queryunload()
>>					_screen.forms[lnForm].visible = .f.
>>					_screen.forms[lnForm].release()
>>				else
>>					return .f.
>>				endif
>>			else
>>				loForm = _screen.forms[lnForm]
>>				release loForm
>>		    endif
>>		endif
>>	endif
>>endfor
>>
>>
>>HTH,
>>
>>Nick
>
>Sorry, Why need so much code??
>Why not:
>Clear ALL
>Close ALL
>Release ALL Extended
>Clear
>
>
>Because Clear ALL and Close ALL will Force close Table!
>The Data should Flush....

Justok, the first reason is the data integrity. This way ensures that all code you specify in QueryUnload() for each opened form for proper closing is fired. Usually, in QueryUnload you check if the record was changed, and if it was it asks user if he wants to save the data. If YES the Form.onSave() method fires Form.Valid() method, which validates the record. What you suggest will work in simple cases, but in general it does not prevent the wrong data from getting into your tables.

The second reason is that not neccesarily all the changes made by user in several opened forms have to be changed. This code leads user through each opened form, reminds about changes made and leaves the final decision for SAVE up to user.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform