Set Of More DOS utilities v28.0a Control-Break/DOS break flag usage document:

The DOS break flag is not reset before any prompt by DOS. This is because
DOS programs in batch files do not trap Control-Break. Instead, DOS will
offer to terminate the batch program when Control-Break is passed to the
next program line in a DOS batch file. This causes DOS programs to send
the ^C character to the next DOS prompt.

Although the utilities will all attempt to terminate during any program
stream running by checking the Control-Break buffer, they will not pass the
Control-Break interrupt to the next program line in a batch file.

This is so the utilities will not send the ^C character to the next prompt,
and is accomplished by using Control-Break trap code for interrupt hex 1B.

This causes having to use multiple Control-Breaks inside batch programs which
have more than one program line of these break trapping utilities.

For example:

  Since Control-Break is checked by reading the keyboard buffer for
  double-byte nuls which are preserved between program calls, and through
  redirection, a utility which uses redirected file input such as:

    Typey /c < File.4

  will exit when Control-Break is set. And a utility which uses redirected
  program input such as:

    Whereis *.txt /c | Typey

  will check the keyboard buffer in both programs and exit when Control-Break
  is set.

  Neither example will send the break state to the next program line in a
  batch program, forcing another Control-Break for each following batch
  program line.

Therefore, a set of DOS break flag state programs are used to clear, set,
detect, and display the break flag value.

DOBREAK.BAT

 This example Batch program checks for the state of the DOS break flag using
 the CHECKBRK program which returns a errorlevel of 128 if the flag is set in
 DOS. Then branching can be done in the Batch program.

 Then value 128 must be checked:

   If errorlevel==128 Goto End1

 The errorlevel variable can contain a value of 0 to 255. A value of 0
 usually indicates the program exited normally.

 Note that 'if errorlevel==x' is compared against the value in x returning
 a true condition if the errorlevel variable is equal to or greater than x.

CHECKBRK.COM

 This utility checks the state of the DOS break flag and returns an errorlevel
 of 128 if the flag is set or an errorlevel of 0 if the flag is not set.

CLEARBRK.COM

 This utility clears the DOS break flag.

COUNTBRK.COM

 This utility displays the value of the DOS break flag.

SETBRK.COM

 This utility sets the DOS break flag.

Example batch program to trap Control-Break with utilities:

clearbrk
stree /r/c
checkbrk
if errorlevel==128 goto end1
whereis /r/l/c
:end1

Also see example batch program EXAMPLE6.BAT and try pressing Control-Break
before the batch processing finishes.

These utilities will also clear the DOS break flag if there is no redirected
input. Additionally the /~ switch resets the DOS break flag for all utilities.

-end-
