Futurebasic/Language/Reference/on break

ON BREAKEdit

StatementEdit

(+) Appearance (+) Standard Console

SyntaxEdit

ON BREAK {FN userFunction|GOSUB{lineNumber|"stmtLabel"}} 

DescriptionEdit

This statement designates a particular function or subroutine as a break-event handling routine. A break-event handling routine is called in response to a cmd-period keypress by the user. After a cmd-period keypress event occurs, FB does not call your designated routine immediately. Instead, your program continues executing until it reaches a HANDLEEVENTS statement; at that time, HANDLEEVENTS will call your designated routine. If the user presses cmd-period but you have not designated any break-event handling routine, your program continues executing until a HANDLEEVENTS is reached; FB then displays an alert asking the user whether to continue or to stop. If the user elects to stop, FB next calls your "stop-event" handling routine, if any (see ON STOP); and then your program stops. If the user elects to continue, the program continues executing at the first statement following the HANDLEEVENTS. One common use for a break-event handling routine is to prevent the user from stopping your program by means of cmd-period.

Your routine can be as simple as this:

LOCAL FN DoBreak
END FN 

This function does nothing, but if you designate it in an "ON BREAK FN DoBreak" statement, then cmd-period keypresses will be "routed" to this function rather than causing the "Stop or Continue" alert to be displayed.

Note:

If you use the ON BREAK FN userFunction syntax, then userFunction must refer to a function which was defined or prototyped at an earlier location in the source code. Your break-event handling function should not take any parameters, nor return a result.

See AlsoEdit

HANDLEEVENTS; ON STOP; TRON X