Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stopping a process
Message
 
 
To
01/03/2011 12:56:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01029879
Message ID:
01502228
Views:
61
>>My CleanUp procedure does not seem to run when I try to shutdown the application and I see an error that this application prevents shutdown...
>
>Of course it doesn't - you reset the 'on shutdown' to default at the end ...
>
>>      on shutdown
>>   endif
>>endif
>
>
I removed that code, but it still does not work. I see my messagebox if I add it to Shutdown procedure, but I don't see log file, etc.
Also, DBC files are still there, not deleted.
procedure CleanUp
local loError, i, j

IF VARTYPE(m.oAppObj) = 'O'
  oAppObj.write_log('Entering ...'  ,program(),'1')
endif  
on shutdown
ON ERROR 
if vartype(oAppObj) <> 'O'
   quit
endif

TRY

   FOR lnI = _screen.Forms.Count TO 1 STEP - 1
   			oAppObj.write_log('Releasing form ' + _screen.Forms[m.lnI].name,program(),'2')
       _screen.Forms[m.lnI].Release()
   NEXT     

   if !empty(oAppObj.SQLHandle)  &&release your connection(s)...
      sqldisconnect(0)
   endif
   close databases all
   SET DATABASE TO 
   if vartype(oAppObj) = 'O'
      if file(oAppObj.cImagesDBC +".DBC")
         delete database (oAppObj.cImagesDBC)
      endif
   endif

catch to loError
   oAppObj.write_log('Error occurred in the CleanUp procedure: ' + loError.message,program(),'1')
endtry

local lcFileName
local array laRV[1]

try
   i = adir(laRV,"RVC_"+'*.*')
   if i > 0
      for j = 1 to i
         lcFileName = laRV(j, 1)
         delete file (lcFileName)
      endfor
   endif
catch to loError
   oAppObj.write_log('Error occurred in the CleanUp procedure: ' + loError.message,program(),'1')
endtry

_screen.controlbox = .t.

if oAppObj.lDevMode
   wait window  'Shutting Down In Dev Mode...'  timeout .5
   if wexist('standard')
      show window 'standard'
   endif
   set status bar on
   set help to              &&can't set help to without foxhelp.hlp
   try
      do quit_prog

      clear all
      close all
      release all
   catch to loError
      IF VARTYPE(oAppObj) = 'O'
	      oAppObj.write_log('Error occurred in the CleanUp procedure: ' + loError.message,program(),'1')
	    endif  
   endtry

   return
endif

if program()=program(1)
   &&not under helperw
   try
      clear all
      close all
      release all
   catch to loError
      IF VARTYPE(oAppObj) = 'O'
	      oAppObj.write_log('Error occurred in the CleanUp procedure: ' + loError.message,program(),'1')
	    endif  
   endtry
endif
CLEAR EVENTS 
return
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform