Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!emory!wrdis01!nstn.ns.ca!uupsi!sunic!news.funet.fi!uwasa.fi!ts From: ts@uwasa.fi (Timo Salmi) Newsgroups: comp.lang.pascal Subject: Re: Ansi Color Message-ID: <1991Apr20.143655.13621@uwasa.fi> Date: 20 Apr 91 14:36:55 GMT References: <1991Apr19.122136.1@tesla.njit.edu> Organization: University of Vaasa Lines: 37 In article <1991Apr19.122136.1@tesla.njit.edu> fer9483@tesla.njit.edu writes: >How di I print ANSI control codes from turbo pascal 5.5? >like the code for a read foreground is: >ESC [31m >how do i print ut using writeln? 26. ***** Q: How to get ansi control codes working in Turbo Pascal writes? A: It is very simple, but one has to be aware of the pitfalls. Let's start from the assumption that ansi.sys or a corresponding driver has been loaded, and that you know ansi codes. If you don't, you'll find that information in the standard MsDos manual. To apply ansi codes you just include the ansi codes in your write statements. For example the following first clears the screen and then puts the text at location 10,10: write (#27, '[2J'); { the ascii code for ESC is 27 } write (#27, '[10;10HUsing ansi codes can be fun'); Now the catches. If you have a uses Crt; statement in your program, direct screen writes will be used, and the ansi codes won't work. You have either to leave out the Crt unit, or include assign (output, ''); rewrite (output); : close (output); Occasionally I have seen it suggested that one should just set DirectVideo := false; This is a popular misconception. It won't produce the desired result. ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun