< Futurebasic < Language < Reference

ON BREAK

Statement

(+) Appearance (+) Standard Console

Syntax

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

Description

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 Also

HANDLEEVENTS; ON STOP; TRON X

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.