Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stopping a process
Message
From
01/03/2011 13:49:06
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01029879
Message ID:
01502237
Views:
61
(1) In the beginning of CleanUp you reset the On ShutDown
If you return then CleanUp is not longer the on('shutdown')

So, returning from CleanUp without touching the On Shutdown prevents quiting foxpro

(2) I see a Clear Events - If you are in runtime - the code after that will not be executed

I have something like this
&& my proc  similar to cleanup

if( not ok to shutdown )
    return
endif

&& here it's ok to shutdown
on shutdown

if( runtime )
    clear events
else
  && some cleanup, then
   quit
endif
The runtime after read events
&& main
...
on shutdown do cleanup

read events
on shutdown && in case from Clear events of a form
  && some cleanup, then
quit
ps: if you set your screen.controlbox on, you can debug it

__________________
>This
>
>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    
>
>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,m.oAppObj.cProgDataDir +"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.
>CLEAR EVENTS 
>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
>ELSE
>	quit
>endif
>
>return
>
>
>does not prevent shutting down the windows, but it does not delete RVC files and doesn't create log file.
>
>Do you see what am I still missing?
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform