Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!uwasa.fi!ts From: ts@uwasa.fi (Timo Salmi) Newsgroups: comp.lang.pascal Subject: Re: Disable Control-Break in TP version 4 Message-ID: <1990Oct11.120204.2912@uwasa.fi> Date: 11 Oct 90 12:02:04 GMT References: <4387@peora.ccur.com> Organization: University of Vaasa Lines: 50 In article <4387@peora.ccur.com> tran@peora.ccur.com (Nhan Tran) writes: > > In Turbo Pascal 3, there is a compiler directive {$C-} that will > disable the Control-Break. > In Turbo Pascal 4, that feature is no longer there. > Does anyone know how to disable Control-Break in TP 4 ?? 1. ***** Q1: I don't want the Break key to be able to interrupt my TP programs. How is this done? Q2: I want to be able to capture the Break key in my TP program. How is this done? A: This very frequently asked question is basically a case of RTFM (read the f*ing manual). But this feature is, admittedly, not very prominently displayed in the Turbo Pascal reference. There is a CheckBreak variable in the Crt unit, which is true by default. To turn if off use uses Crt; : CheckBreak := false; : Besides turning off break checking this enables you to capture the pressing of the break key as you would capture pressing ctrl-c. In other words you can use e.g. : procedure TEST; var key : char; begin repeat if KeyPressed then begin key := ReadKey; case key of #3 : begin writeln ('Break'); exit; end; {ctrl-c or break} else write (ord(key), ' '); end; {case} end; {if} until false; end; (* test *) : This is, however, not all there can be to it, since the capturing is possible only at input time. It is also possible to write a break handler to interrupt a TP program at any time. For more details see Ohlsen & Stoker, Turbo Pascal Adavanced Techniques, Chapter 7. ................................................................... Prof. Timo Salmi (Moderating at anon. ftp site 128.214.12.3) School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun