home *** CD-ROM | disk | FTP | other *** search
- { BREAK -- A unit to allow Control-Break to interrupt program execution.
-
- Version 1.00 - 1/02/1987 - First general release
-
- Scott Bussinger
- Professional Practice Systems
- 110 South 131st Street
- Tacoma, WA 98444
- (206)531-8944
- Compuserve 72247,2671
-
- This unit for Turbo Pascal version 4.0 allows you to stop execution of a
- program by hitting CONTROL-BREAK at any time. Unlike the standard ^Break
- handler provided by the CRT unit, this unit will interrupt a program at any
- time and not just during I/O statements. This is akin to the old $U+
- directive that Turbo Pascal version 3 had, but without the severe execution
- overhead. Using the BREAK unit will not slow down your program noticably!
- To include this unit in your program, add BREAK to the USES clause in your
- main program.
- This unit exports no identifiers, so other than adding it the the USES
- statement, you'll ee no difference in execution or programming. The only
- tricky thing is that the BREAK unit MUST be listed in the USES statement
- after any other unit which installs a ^Break handler (notably the CRT unit).
- For this reason, I suggest it be the last unit in the list. The reason for
- this is that most ^Break handlers don't chain to older handlers, but rather
- just handle it themselves. This includes the BREAK unit. I tried chaining to
- other handlers, and ran into some problems, so I'd recommend just leaving
- things as they are.
- The basic technique the unit uses is to set a flag when ^Break is struck and
- look for this flag to be set on every clock tick. If the flag is set and the
- program is currently executing in the Pascal code (and not in DOS or TSR or
- ???) it then immediately halts. It is possible to get into a loop where ^Break
- isn't recognized if the program is executing in DOS or BIOS for example.
- Compile and run this file as a demonstration of using BREAK. The program
- will into a 10 second delay and print a message if you don't do anything. You
- can interrupt the program at any time however by striking ^Break. }
-
- program Test;
-
- uses Crt,Break; { Note that Break _must_ follow CRT! }
-
- begin
- delay(10000);
- writeln('Got to end of program.')
- end.