Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!csun!Twg-S5!abcscnuk From: abcscnuk@Twg-S5.uucp (Naoto Kimura (ACM)) Newsgroups: comp.lang.pascal Subject: Re: Disable Control-Break in TP version 4 Message-ID: <1990Oct12.111159.23213@csun.edu> Date: 12 Oct 90 11:11:59 GMT References: <4387@peora.ccur.com> <1990Oct11.120204.2912@uwasa.fi> Sender: news@csun.edu (News Administrator) Organization: csun Lines: 91 In article <1990Oct11.120204.2912@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes: ]... ( stuff deleted ) ... ] ] 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. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Quite true! It took me quite a while trying to remember where I saw it (in the description of the Crt unit), so I could mention the page number on which it appeared. I found it a few days ago, but I can't say what page number since I don't have the manual with me. ] There is a CheckBreak variable in the Crt unit, which is true by ]default. To turn if off use ] uses Crt; ] : ] CheckBreak := false; ] : One interesting point about the CheckBreak variable is that it is the same as the *undocumented* CBREAK variable in version 3.0 (I remember finding it one day when snooping around in the executable with a binary file editor and never knew what it was for until I read the manual for version 4.0). This fact is mentioned in the appendix discussing the differences between version 3.0 and version 4.0/5.0. ]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. Minor correction is needed in the code: ] : ]procedure TEST; ]var key : char; ]begin ] repeat ] if KeyPressed then ] begin ] key := ReadKey; ] case key of (* account for special keys (F1..F10, arrows, etc.) *) (* otherwise we can misinterpret them *) #0 : begin write(' (0,',ord(ReadKey),') '); Key := ReadKey; end; ] #3 : begin writeln ('Break'); exit; end; {ctrl-c or break} ] else write (ord(key), ' '); ] end; {case} ] end; {if} ] until false; ]end; (* test *) ] : The above code would change slightly for version 3.0: ]procedure TEST; ]var key : char; ]begin ] repeat ] if KeyPressed then ] begin ] key := ReadKey; ] case key of (* account for special keys (F1..F10, arrows, etc.) *) (* otherwise we can misinterpret them *) #27 :if not KeyPressed then write('27 ') else begin write(' (0,',ord(ReadKey),') '); Key := ReadKey; end; ] #3 : begin writeln ('Break'); exit; end; {ctrl-c or break} ] else write (ord(key), ' '); ] end; {case} ] end; {if} ] until false; ]end; (* test *) ]... ( stuff deleted ) ... ]................................................................... ]Prof. Timo Salmi (Moderating at anon. ftp site 128.214.12.3) //-n-\\ Naoto Kimura _____---=======---_____ (abcscnuk@csuna.csun.edu) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!