Hi.

Recently I discovered that Delphi can detect [Ctrl]+C keys using the
EControlC exception. I was curious so I decided to test it in Linux
using Free Pascal. The program I wrote:
_________________________________

PROGRAM ExControlC;
(* How to capture [Ctrl+C] in Object Pascal.  *)

{$mode objfpc}{$H+}

USES
  SysUtils;

VAR
  Tmp: STRING;
BEGIN
  TRY
    WriteLN ('Press [Enter] or [Ctrl+C].');
    ReadLN (Tmp);
    WriteLN ('You pressed [Enter].');
  EXCEPT
    ON EControlC DO WriteLN ('You pressed [Ctrl+C].');
  END;
  WriteLN ('Have a nice day.');
END.
_________________________________

That's simple. I tested it on Linux but it doesn't worked. It compiles
and run, but if you press [Ctrl]+C the program exits without the "You
pressed [Ctrl+C]." message. Is it an issue or a bug? May be it's not
possible to detect [Ctrl]+C in Linux?

Guillermo "Ñuño" Martínez
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to