Getting started with Pascal here. I wanted to write a simple program that first clears the terminal window and then reads user input. The first result of searching for clearing the screen showed the ClrScr procedure. Using it gets the job done but ClrScr needs Crt which results in a new problem. Terminating the program using Ctrl + C does not work. Searching online again, I found that Crt takes over I/O. I have been looking for alternative to ClrScr but haven't really found anything so far.
So how can I clear terminal while still being able to terminate the program using
Ctrl + C. Also how can I terminate the program in the current case usingCrt?
Current Code:
program Test;
uses Crt;
var
x : integer;
begin
read(x);
end.
Crt, is to catchCtrl+Cby reading it as a key and acting on it explicitly. - lurker^Cas a key (usingKeyPressed,ReadKey) at appropriate places and react to it. On Windows, there is aSysSetCtrlBreakHandler, but I don't know if that exists on other platforms. - Rudy Velthuis^Cseems the only way to do it and something that I don't feel like implementing. Might just discardCrtfrom the code totally. - user4447799