CTRL+BREAK Does Not Abort Basic PDS's INKEY$ If No BC /D (72718)



The information in this article applies to:

  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q72718

SUMMARY

If you compile without the BC /D (debug) option in Basic PDS versions 7.0 and 7.1, pressing CTRL+BREAK will cause the INKEY$ function to return two null bytes and program execution will continue without breaking. In contrast, when compiled with BC /D, or run in QBX.EXE, an INKEY$ loop will not input CTRL+BREAK, and CTRL+BREAK will abort the program (unless trapped with ON KEY GOSUB key-trapping statements).

This information applies to Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS and MS OS/2.

In versions of Basic earlier than 7.0, the INKEY$ function never returns bytes for CTRL+BREAK, and CTRL+BREAK always aborts the program (unless trapped with ON KEY GOSUB key-trapping statements).

MORE INFORMATION

The following code example demonstrates this.
CLS
PRINT "press CTRL+BREAK..."
WHILE a$ = ""
 a$ = INKEY$
WEND
PRINT "length="; LEN(a$); "byte values=";ASC(a$); ASC(RIGHT$(a$, 1))
PRINT "This will print without BC /D, but not with BC /D or QBX.EXE"
END
				
Compile the code example both with and without the BC /D option for comparison. Without the /D option, the CTRL+BREAK keystroke is passed on to the program and execution continues, so the two PRINT statements after the LOOP will be printed. When compiled with BC /D, or run in QBX.EXE, or compiled with Basics earlier than 7.0, the program halts execution and the PRINT statements are never executed.

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:KB72718