문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top