ECHO--Examples
The following example shows a batch program that includes a three-line
message preceded and followed by a blank line:
echo off
echo.
echo This batch program
echo formats and checks
echo new disks
echo.
If you want to turn ECHO off and you do not want to echo the ECHO command
itself, include an at sign (@) before the command, as follows:
@echo off
You can use the IF and ECHO commands on the same command line, as follows:
if exist *.rpt echo The report has arrived.
EchoGood.bat (from a.m.b, February 17, 2001)
call EchoGood 7 --- would echoing 007 on the screen
call EchoGood 45 --- would echoing 045 on the screen
call EchoGood 184 --- would echoing 184 on the screen
Often we wanted a good layout of an output.
Example: N=7
ECHO %N%
and we got 7 on the screen but in some cases it can be difficult to
compare different values of an output.
In such a case, it's better to look at 007 instead of just 7 and to
look at 045 instead of 45, i.e. for all numbers 0 through 999, it's
some times better to looking at three digits for all those numbers.
I was searching a solution in about 2 or 3 lines, but I found a two
liners solution in PURE DOS and I think that's better than if the 3
party utillity the STRINGS.COM (a three liners solution) were used.
@ECHO OFF
SET N=7
:: ------------------------ Here it goes:
ECHO..| CHOICE /C'%N%.> NUL
IF not errorlevel 5 FOR %%D in (0 00) do IF not errorlevel Y%%D SET N=%%D%N%
:: ------------------------
ECHO. [%N%]
SET N=
The following is an extern version.
Examples:
call EchoGood 7 --- would echoing 007 on the screen
call EchoGood 45 --- would echoing 045 on the screen
call EchoGood 184 --- would echoing 184 on the screen
-------------------------------------------
:: EchoGood.bat: (5 lines and 136 bytes)
::
SET N=%1
ECHO..| CHOICE /C'%1.> NUL
IF not errorlevel 5 FOR %%D in (0 00) do IF not errorlevel Y%%D SET N=%%D%1
ECHO. [%N%]
SET N=
Notes:
If I wrote: IF "%N%"=="" SET N=0, then (in both solutions), no contents of
%N% would be displayed as three zeros.
Benny Pedersen,
http://users.cybercity.dk/~bse26236/
PS.
OFF-Topic. A News Group is a place where all people in this world can ask
another about a solution or a problem. All who got an Internet connection
can write answers to those questions and we can all see anothers question
and answers.
A guy from Belgium? He wrote to all people and here goes my answer:
"D'haveloose Rik" wrote:
...[SNIP SNAP]
> that involves 2 translations (first
> Benny, and then here (dutch-native, French oriented, German alike)
>
> What the f.... hell did they do in Babel .... :^((
Nothing special. Among other things we build the tower
& they told me that I was promoted to English teacher.
Benny
|