tran@peora.ccur.com (Nhan Tran) (10/08/90)
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 ?? Nhan Tran Email: tran@peora.sdc.ccur.com
nkraft@crash.cts.com (Norman Kraft) (10/09/90)
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 ?? In TP 4.0-5.5 there is a global boolean variable called CheckBreak (comes from the System unit, automatically included). Set this to FALSE to do what the {$C-} did in TP 3.0. -------------------------------------------------------------------------- Norman R. Kraft "Things should be as simple Director, Software Development as possible, but not simpler." Postal Buddy Corporation, San Diego, CA - Albert Einstein INET nkraft@crash.cts.com UUCP {hplabs!hp-sdd ucsd nosc}!crash!nkraft Usual disclaimer applies... --------------------------------------------------------------------------
Adams@J (jma@gnu.ai.mit.edu) (10/11/90)
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 ?? In Turbo Pascal 5 and up you can just set ControlBreak := False And it'll shut it down, I think it's the same as far as 4.0 goes too.. -+-+-+- -+-+-+- John Adams INTERNET -> jma@gnu.ai.mit.edu "What you get is all real; I can't put on an act, it takes brains to do that anyway..." -- XTC -=-=-=- -=-=-=-
ts@uwasa.fi (Timo Salmi) (10/11/90)
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
abcscnuk@Twg-S5.uucp (Naoto Kimura (ACM)) (10/12/90)
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 !!
ts@uwasa.fi (Timo Salmi) (10/13/90)
In article <1990Oct12.111159.23213@csun.edu> abcscnuk@Twg-S5.uucp (Naoto Kimura (ACM)) writes: >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. The page numbers on the TP 4.0 manual are not useful anyway, since there are different versions in circulation with slightly divergent placing of items. >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; Minor correction of the correction is needed :-). Run and test the original code. It works as it was. ................................................................... 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