Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: recovering from cancel terminate cancel button oncancel
:CANCELin the WinBatch script. If we do not find it, the script is cancelled. If we find it the script continues.
The function IntControl( 72,…) lets you specify what should happen when the next Cancel event occurs in the script. This allows the program developer to perform cancel processing, if a user presses Cancel, in any dialog. When processing goes to :CANCEL, the following WIL variables are automatically set:
Variable Type Meaning ------------------------------------------------ wberrorhandlerline (s) Cancel line (ie, line in script that caused Cancel) wberrorhandleroffset (i) offset into script of Cancel line, in bytes wberrorhandlerassignment(s) variable being assigned on Cancel line, or "" if none wberrorhandlerfile (s) name of the currently-executing script wberrortextstring (s) description of the WIL error wberroradditionalinfo (s) additional error information, if any wberrorinsegment (s) name of the currently-executing UDF, or a blank string ("") if not in a UDF. wberrorarray (a) WIL array with the following elements: wberrorarray[0] = LastError() wberrorarray[1] = wberrorhandlerline wberrorarray[2] = wberrorhandleroffset wberrorarray[3] = wberrorhandlerassignment wberrorarray[4] = wberrorhandlerfile wberrorarray[5] = wberrortextstring wberrorarray[6] = wberroradditionalinfo wberrorarray[7] = wberrorinsegment
Note: The Windows operating system offers many alternatives, for canceling a dialog: pressing the Cancel button, typing Esc, Alt-F4, and some others.
;TITLE: ;DATE: ;AUTHOR: ;VERSION: ;UPDATED: ;PURPOSE: IntControl(72,2,0,0,0) abc=Pause("Pause","one") Message("ABC is",abc) def=Pause("Pause","two") Message("def is",def) Exit :CANCEL %wberrorhandlerassignment% = 9999 IntControl(72,2,0,0,0) return
;; TOP OF FILE ONCANCEL="EXIT" Dialog1(xxxxx etc ) ONCANCEL="GOTO DIALOG" Dialog2(xxxxx etc. ) ONCANCEL="GOTO DIALOG2" Dialog(xxxx etc. ) :CANCEL %ONCANCEL% EXIT
<-------snip---------> ; Simple example a=AskYesNo("testing","Press the cancel button") :can1 Message("Testing","Value of A is %a%") exit :cancel a=-1 goto can1 <-------------snip------------->
<---------snip--------------> oncancel="exit" xxx=AskYesNo("Testing","If you press cancel now the script will exit") a=-1 oncancel="goto can1" a=AskYesNo("Testing","Press Cancel") :can1 Message("testing","Value of A is %a%") a=-1 oncancel="goto can2" a=AskYesNo("Testing","Press Cancel") :can2 Message("testing","Value of A is %a%") oncancel="exit" xxx=AskYesNo("Testing","If you press cancel now the script will exit") exit :cancel %oncancel% exit
ONCANCEL="GOTO REDRAW" :REDRAW types="All Files|*.*|WIL Files|*.wbt;*.mnu|Text Files|*.txt|" fn1=AskFileName("SelectFile", "C:\WinBatch", types, "Sol.wbt", 1) Message("File selected was", fn1) ;EEEP ADD EXIT :CANCEL %ONCANCEL% EXIT
One solution that works for me is to place the dialog in a separate wbt file that can be called from the main script.
In the subsidiary call file you can have a :cancel subsection where oncancel="Return", thus returning you to the main script at precisely the point you want to be.
Article ID: W12994
Filename: How to Prevent Cancel Button from Quitting App.txt
File Created: 2004:09:27:12:41:54
Last Updated: 2004:09:27:12:41:54