Trapping the BREAK Key

Bob @ MidCity Office bob at midcityoffice.com
Mon Feb 23 10:52:30 PST 2009


Hi
 
The thread last week reminded me of some processing I wrote to trap BREAK. Normally when you hit Control-C you immediately exit the application. The only way I could find to trap the Control-C was this:
First, most of my applications run from a Stand File, if I'm doing Customer Maintence, I copyin the customer record, make my changes and copy back to customer file. Because of the method, I also turn SAVE OFF, so I can save my changes to the customer file and not the file I'm standing on. With BREAK OFF it seems you can't use @sk, but you can use it for the Escape key wIith SAVE OFF. The only solution was to set PFSKHEX=ON. Control-C = "0003".
You can test this input processing by creating a 1 field file, and goto Add Records.
 
::end:
@wef1::cls("21") ; save off ; break off:
::showctr("22") "Press \K4 to Save, Press \KY to Exit":
::show (@ro, at co) "":
loop::sk = waitkey:
:@sk eq "entr":screen  ,1:
:@sk eq "save":gosub saveit ; screen  ,1:
:@sk eq "0003":gosub QuitYN:
:Quit eq "Y":delete ; close ; exit:
::screen  ,1:
::goto loop:
::end:
QuitYN::msgbox "Quit ?","Y or N","yn":
:@bk eq "y":Quit = "y" ; return:
:@bk ne "n":goto QuitYN":
::return:
saveit::msgbox "Saving Data":
::return:
declare::declare Quit:
 
 
  1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: end
  2  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
@wef1  ◄ If:
       Then: cls("21") ; save off ; break off
  3  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: showctr("22") "Press \K4 to Save, Press \KY to Exit"
  4  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: show (@ro, at co) ""
  5  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
loop   ◄ If:
       Then: sk = waitkey
  6  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: @sk eq "entr"
       Then: screen  ,1
  7  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: @sk eq "save"
       Then: gosub saveit ; screen  ,1
  8  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: @sk eq "0003"
       Then: gosub QuitYN
  9  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: Quit eq "Y"
       Then: delete ; close ; exit
 10  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: screen  ,1
 11  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: goto loop
 12  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: end
 13  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
QuitYN ◄ If:                                                                   
       Then: msgbox "Quit ?","Y or N","yn"                          
 14  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: @bk eq "y"                                                 
       Then: Quit = "y" ; return                                               
 15  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If: @bk ne "n"                                                        
       Then: goto QuitYN"                                                      
 16  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:                                                                   
       Then: return                                                         
 17  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
saveit ◄ If:                                                                   
       Then: msgbox "Saving Data" ; return                        
 18  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
declare◄ If:                                                                  
       Then: declare Quit                                                  
 
 
Bob Simcoe
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.celestial.com/pipermail/filepro-list/attachments/20090223/5e702fca/attachment.html 


More information about the Filepro-list mailing list