billq@ms.uky.edu (Billy Quinn) (09/05/90)
Is there any way I can compile a program written in pascal (Turbo PASCAL) version 4.0, so that the program won't terminate with the ^C or ^[break] keys? It's seems that other versions of TPascal have compiler directives to do such a thing but for some reason, version 4.0 does not accept these compiler directives. Other programmers have told me of an un-documented command called 'cbreak' whic is supposed to be set to 'true' to control this sort of thing, however, I connot get this to work either. Any help will be greatly appreciated! Billy Quinn (billq@ms.uky.edu) -- Billy Quinn (billq@ms.uky.edu) (pr01527@ukpr.uky.edu) (home phone: 606-233-1568)
spolsky-joel@cs.yale.edu (Joel Spolsky) (09/06/90)
In article <billq.652551823@s.ms.uky.edu> billq@ms.uky.edu (Billy Quinn) writes: >Is there any way I can compile a program written in pascal (Turbo PASCAL) >version 4.0, so that the program won't terminate with the ^C or ^[break] >keys? One way to do this: - use the bios directly to get all keystrokes; there is a function in TurboPascal (probably called BiosKey or something) to do this. That will let you get ^C, ^S, ^P, ^Q, and lots of other goodies that would otherwise have special meaning. - install your own ctrl-break handler. For this I refer you to any good book on programming with interrupts, or the interrupt list. Basically you need to use the DOS getvector function to find out where ctrl-break's are going, then DOS setvector to redirect them to one of your functions, then finally setvector when your program exits to restore the original Ctrl-Break handler. Perhaps there is some built in Turbo Pascal-specific way to do this? Joel Spolsky spolsky@cs.yale.edu Talk Hard.
ts@uwasa.fi (Timo Salmi LASK) (09/07/90)
In article <billq.652551823@s.ms.uky.edu> billq@ms.uky.edu (Billy Quinn) writes: >Is there any way I can compile a program written in pascal (Turbo PASCAL) >version 4.0, so that the program won't terminate with the ^C or ^[break] >keys? It's seems that other versions of TPascal have compiler directives >to do such a thing but for some reason, version 4.0 does not accept these >compiler directives. Other programmers have told me of an un-documented >command called 'cbreak' whic is supposed to be set to 'true' to control >this sort of thing, however, I connot get this to work either. Any help >will be greatly appreciated! This is one of the most frequently asked questions about TP. The statement about TP 4.0 not having this feature is false. Just take a look at your TP 4.0 manual for the CheckBreak keyword. And, it is not a compiler directive but a predefined constant that can be set true (default) or false. If it is false, you can capture ^C and the break key by testing if ReadKey returns a #3. (CBreak is an obsolete Turbo Pascal version 3 keyword). Also note that in order to be able to use CheckBreak, you'll have to include the Crt unit in your uses statement. I hope this helps you in the right direction. ................................................................... 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