Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error Handling (Shutdown problem)
Message
From
05/10/2000 09:09:03
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
 
 
To
05/10/2000 07:40:52
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00425207
Message ID:
00425243
Views:
21
Code such as this may help you exit more gracefully. Seems like the easy things got much more difficult in windows:

* attempt to clean up environment
LOCAL numforms,i,x,tcontrols,demembers,toselect,looped
numforms=_screen.formcount
looped=0
on shutdown
do while .t.
for i=1 to numforms
if type('_screen.forms[i]')='O'
* need code here to check dataenvironment
* and close tables reverting them as necessary
IF !ISNULL(_screen.forms[i])
* first, is this form using a private data environment?
* assumes all forms are using data buffering
SET DATASESSION TO _screen.forms[i].datasessionid
if _screen.forms[i].datasession=2 && is private
if type('_screen.forms[i].dataenvironment')<>'O'
loop
endif
release demembers
dimension demembers[1]
=amembers(demembers,_screen.forms[i].dataenvironment,2)
if vartype(demembers)='L'
_screen.forms[i].visible=.f.
_screen.forms[i].release()
loop
endif
tcontrols= alen(demembers,1)
for x=1 to tcontrols
* is it a cursor, table, relation
* check for readonly to keep from writing over changes to tables like company etc when it is not intended.
if upper(_screen.forms[i].dataenvironment.&demembers [x]..class)='CURSOR' AND ;
!_screen.forms[i].dataenvironment.&demembers[x]..readonly=.t.
toselect= _screen.forms[i].dataenvironment.&demembers[x]..alias
if used(toselect)
select (toselect)
if cursorgetprop('buffering')>1
* is it row or table buffering doesn't matter
=tablerevert(.t.)
endif
endif
endif
next
* close the tables - this is done by the form release method.
endif
_screen.forms[i].visible=.f.
_screen.forms[i].release()
ENDIF
endif
next
looped=looped+1
numforms = _screen.formcount
if numforms= 0 or looped=3
exit
endif
enddo
on shutdown
on error do X_nothin
this.quitloop=.t.
clear events
return to main
* this is form development environment
set sysmenu to default
set datasession to 1
close tables all
*!* clear all
*!* clear all
*!* clear all
ON ERROR
A problem is a problem only as long as it has a possible solution. Lacking that, it becomes a FACT!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform