echoc

Download

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.

Synopsis

echoc bg fg <text>

Parameters

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
const
  // 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:

1
2
3
4
5
6
7
@echo off
echo.
echoc 15 0 This is black on white
echo.
echoc 14 12 This is bright       red on yellow
echo.
echo.

Screenshot of first batch

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

1
2
3
@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

Legalese

I hope this code is useful to you. If you use some of it, please credit me. If you modify or improve the program, please send me the modifications.

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