An up-to-date version of this and other files can be found in my CommandLineTools project on GitHub.

This is a little program I wrote on request. Someone had used Timo Salmi’s ECHOC command line program, but it ruined the buffer if the window was not 80×25. The person asking had seen my Console unit and asked me if I could write a program that did the same, using the Console unit.

The program outputs the main part of the command line using the foreground and background colours given. Using the Console unit, it was really a piece of cake.

I removed the dependency on the Console unit.


echoc bg fg <text>


The fg and bg parameters can have values of 0..15 and constitute the foreground and background colour of the line respectively. The colours are the colours given in Console.pas:

  // Background and foreground colors
  Black        = 0;
  Blue         = 1;
  Green        = 2;
  Cyan         = 3;
  Red          = 4;
  Magenta      = 5;
  Brown        = 6;
  LightGray    = 7;

  // Foreground colors
  DarkGray     = 8;
  LightBlue    = 9;
  LightGreen   = 10;
  LightCyan    = 11;
  LightRed     = 12;
  LightMagenta = 13;
  Yellow       = 14;
  White        = 15;

Blinking is not supported, and the blink bit will set the top bit of the background colour, so you have all 16 colours shown above as background too.

The rest of the parameters is simply displayed, each parameter separated by one space character. But if you put parameters in quotes, the text will be taken literally, and multiple spaces will be displayed, if they appear in the string.

The original program would not display any newlines, so to get newlines, you had to do something like:

@echo off
echoc 15 0 This is black on white
echoc 14 12 This is bright       red on yellow

Screenshot of first batch

I decided to add a special character to the string to indicate a newline: ^. So now you can do:

@echo off
echoc 15 0 "^This is black on white^"
echoc 14 12 "This is bright       red on yellow^^^with newlines^^"

Screenshot of second batch


Plase respect the license in the files.

I may improve or enhance echoc myself, and I will try to post changes here. But this is not a promise. Please don’t request features.

Rudy Velthuis

Standard Disclaimer for External Links

These links are being provided as a convenience and for informational purposes only; they do not constitute an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual. I bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.

Disclaimer and Copyright

The coding examples presented here are for illustration purposes only. The author takes no responsibility for end-user use. All content herein is copyrighted by Rudy Velthuis, and may not be reproduced in any form without the author's permission. Source code written by Rudy Velthuis presented as download is subject to the license in the files.

Back to top