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?
-
4@Neil Butterworth, just nostalgia. There is something very relaxing and satisfying about escaping from today's world of immense, opaque libraries and instead pretending to be back in the day when there was only you, your code, the machine, and a library small enough to understand. And I must say that even after all these years, Turbo Pascal is a pleasant working environment—and the Pascal language sucks less now that I have the knowledge and experience to Greenspun the heck out of it! – Vebjorn Ljosa Apr 21 '10 at 14:27
-
I know what you mean - I have happy memories of working on CP/M - no libraries, everything written in Z80 assembler. I can't help with the break-in key, I'm afraid - my experience was always that you had to hit the reset button and then dive into the monitor (that's a built-in debugger for any young folks out there) to find out what had happened. – Apr 21 '10 at 14:42
2 Answers
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.

- 77,689
- 9
- 166
- 211
At the start of your Turbo Pascal 3 program (under the Program
statement) is Compiler Directive {$U+}
. This should allow you to do a CTRL + C. Always use this only while you're debugging your program as it slows down the execution speed of your program. 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 the execution speed of the program or if it was the use of a nested loop which led to this occurring.

- 6,861
- 1
- 27
- 28

- 61
- 1
- 2