Dec 172017
Enhanced Echo command for DOS. Includes ASM source code.
File ECHJ.ZIP from The Programmer’s Corner in
Category Batch Files
Enhanced Echo command for DOS. Includes ASM source code.
File Name File Size Zip Size Zip Type
ECHJ.ASM 24872 6016 deflated
ECHJ.COM 2095 1525 deflated
ECHJ.DOC 6685 2480 deflated

Download File ECHJ.ZIP Here

Contents of the ECHJ.DOC file

ECH.COM (what DOS's ECHO should have been)

ECH echoes each character in its argument to standard output,
subject to certain character sequences that allow you to:

(1) output any of the 256 extended ASCII codes, which may be
specified in decimal or in hex;

(2) conveniently specify the special control codes (newline,
form feed, backspace, escape, etc.);

(3) cause the screen to be dumped to the printer;

(4) erase the screen;

(5) wait for a given number of tenths of a second;

(6) output a range of characters between and including
any two specified extended ASCII characters;

(7) output one character randomly selected from a range of
extended ASCII characters;

(8) output a 5-digit decimal number (right-justified, space-
filled) that starts at 1 and is incremented at every use;

(9) repeat any ECH function a specified number of times; and

(10) output a 5-digit decimal number (right-justified, space-
filled) within a repeat string that starts at the repeat
count and counts back to 1.

The left bracket ([) is ECH's most special character, indicating that the
character or characters following it have special meaning. Use [[ when you
want to output a single [.

The right bracket (]) is sometimes needed to indicate the end of an evaluated
number (ASCII code or repeat count - see below). It does not appear in the
output stream in these situations. Use [] if you want it to.

{ indicates the start of a repeat string, and } indicates its end (see below).
Use [{ and [} if you want actual braces in your output.

A semicolon (;) will indicate a newline (carriage return followed by line
feed) only if it is the first character in the argument to ECH (i.e., the
first character after the first space after "ECH"). All subsequent
occurrences of ; in ECH's argument will be replaced by a newline. Use [;
if you actually want a semicolon. If ECH's first argument character is
not a semicolon, then any semicolons in the argument will be echoed as
semicolons (and so still will occurrences of [;).

ECH ;;; = 2 (not 3) newlines.
ECH ;;; = ;;;

ASCII codes: [ or [] where is hex if
it begins with a 0, decimal if it begins with 1...9, and not a number
otherwise. Use ] to end the number if the next character after the
desired ASCII code could be mistaken for a digit of the number (the ]
terminating an ASCII code will not be echoed).

ECH [7a = a
ECH [07a = z
ECH [07]a = a

Screen functions: [v or [V erases the screen (video very void). [p or [P
is the print screen command (DOS INT 5) - if embedded in a repeat string,
ECH will try to dump the screen contents every time the [p or [P is
encountered, so make sure that's what you want.

Wait function: [w or [W waits for that number of tenths of
a second.

ech [w10 = wait for 1 second
ech [w010 = wait for 1.6 seconds

Repeated strings: {} where is the repeat count
and is any string of one or more characters (literal, special, or
ASCII codes) terminated by a }. Use [{ or [} to include actual braces in
a repeated string. Repeated strings may be nested to a "reasonable" depth.
As with ASCII code numbers, terminate the repeat count with a ] if the next
character might be mistaken for a digit of the number (the [ will not
appear in the output stream).

ECH a{0a]b}c = abbbbbbbbbbc (the [ is necessary)
ECH {10junk[n} = ten lines of "junk" (see below for [n)
ECH ;{10+ {3garbage };}last line;
= ten lines of "+ garbage garbage garbage " followed by
one line of "last line"

All-of-range function: [a or [A outputs all of
the characters from to inclusive. The range may be ascending
or descending (so you need two ranges if you want to wrap over the [0/[255
border) and the range limits may be specified in any way that yields a single

ech [aza = zyxwvutsrqponmlkjihgfedcba
ech [a[0[255 = entire extended ASCII character set (remember that
backspace, carriage return, line feed, etc., will
do funny things)

One-of-range function: [o or [O (use the letter
"o" and not the digit zero) outputs just one character selected randomly
from the range of characters specified by the fearsomely named multiplicative
congruential pseudo-random number generator.

ech {10{3[o09} }[n = ten 3-digit numbers
ech ;{10{15{4[oaz} };} = ten lines of fifteen four-letter words each

Counter: [c or [c outputs a 5-digit, right-justified, space-filled decimal
number that starts at 1 and grow by 1 each time it is used.

ech ;{100[c;} = 1 to 100, one per line

Iteration counter: [i or [I outputs a 5-digit, right-justified, space-filled
decimal number within a repeat loop that starts at the repetition count
specified for the current (innermost active) loop and counts back to 1 by 1.
If used outside a repeat loop, you just get 1.

ech ;{100[i;} = 100 to 1, one per line
ech ;{5[i {2[i };} = 5 2 1
4 2 1
3 2 1
2 2 1
1 2 1

Special codes:

[n = [N = newline = [13[10 = [0d[0a = (sometimes) ;
[e = [E = escape = [27 = [01b
[t = [T = tab = [9 = [09
[f = [F = form feed = [12 = [0c
[b = [B = backspace = [8 = [08
[r = [R = carriage return = [13 = [0d
[s = [S = space = [32 = [020 (use if no actual spaces allowed)
[l = [L = line feed = [10 = [0a

[[ = [ [] = ] [; = ; [{ = { [} = }

Error messages are written to the screen (STDERR file handle) regardless of
where you're trying to direct the output. The entire argument is scanned
for errors before any output takes place, so you won't get partial output
and then a snotty message - you'll just get the snotty message.

 December 17, 2017  Add comments

Leave a Reply