Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!comp.vuw.ac.nz!canterbury!phys169 From: phys169@csc.canterbury.ac.nz Newsgroups: comp.lang.pascal Subject: Re: Extracting from a unit (or CRT vs. ANSI) Message-ID: <1991Apr10.104252.422@csc.canterbury.ac.nz> Date: 9 Apr 91 22:42:52 GMT References: <26447@adm.brl.mil> Organization: University of Canterbury, Christchurch, New Zealand Lines: 42 In article <26447@adm.brl.mil>, 209507097@ucis.vill.edu (MCREE, JAMES F) writes: > > I need to use the "KeyPressed" and "ReadKey" functions in CRT in Turbo > 5.0, but can't use the CRT unit because it will cause the program to ignore the > meaning of my ANSI codes. There are three general ways that I can think of for > getting this to work. > > 1. Extract these two functions directly out of the CRT unit and compile > them separately or include the code directly in my program. Not worth trying, especailly as there is important other stuff in the unit you might miss, e.g. during startup. > 2. Write new code or reverse-engineered code to perform these > functions. Pretty simple, many others have supplied examples. They're short routines, and worth using in-line assembler (ask me for a copy if you want my versions of these routines). > 3. Tell CRT to ignore ANSI escape sequences. > Probably the best idea for what you're after, you can use the CRT unit and still write to the standard output, e.g. assign (output,''); rewrite(output). There are some related questions worth talking about, though... 1. Why do you want to use ANSI escape sequences? If the answer is because you might want to use the CTTY command to run the program from a terminal on a coms port, then the above suggestions about ReadKey and KeyPressed (using BIOS interrupt $16) are invalid, and you should test for the standard input being ready. It's probably unlikely that's what you're after, but just in case it is, there are DOS calls that do a pretty good job. If you want to redefine function keys, consider assign(input,''); reset(input) as well. 2. Some poeople want to use the features of the CRT unit but avoid the risk of crashing during startup on incompatible hardware (e.g. the Data General DG10 - but not DG1 - falls over in a major way during the automatic startup code that is executed when you include the CRT unit). I have a unit that I could make public, that duplicates most of the CRT unit but runs okay on some "odd" computers like the DG10 and Sanyo MBC550's. Let me know if anyone wants it... Hope this helps, Mark Aitchison, Physics, University of Canterbury, New Zealand.