I am running Turbo Pascal 3.01A on CP/M 2.2. Suppose my Pascal program, which I run using the R menu option in Turbo Pascal, has a bug and goes into an infinite loop. Is there a special control character that will interrupt my program and return to the Turbo Pascal menu?
What you can put at the start of your Turbo Pascal 3 program (under the Program statement) is Compiler Directive {$U+} when this is active this should allow you to do a CTRL-C. Always use this only while your Debugging your program as it slows down the execution speed of your program and if it runs okay, remove it and then compile your program.
Typically in Turbo Pascal 3 the compiler has a set of Default Compiler Directives, The U - User Interrupt is typically off by default. The other thing I found in my Turbo Pascal program just recently was I was using this while debugging my program and for some reason it wasn't working. Not sure what was going on there and found I really had to hold down this combination to get the program to exit. Unsure if it had something to do with Executation speed of the program or if it was use of a Nested Loop which lead to this occurring.
The {U+} directive will cause the compiled code to check after each statement whether a key has been hit. If so, the keystroke will be checked for ^C; if not ^C the keystroke will be discarded. While this usefully allows the program to be aborted, it slows things down and also rather annoyingly kills type-ahead ability. Unfortunately, CP/M doesn't provide any sort of keyboard interrupts (though some CP/M implementations might provide one) so there's not really any better alternative. It would be nice if Turbo Pascal had an option to implement its own keyboard buffering, but I don't know of any.