Page 1 of 1
Echoing /?
Posted: 26 Jan 2011 19:50
by Kligham
Hi,
I have a little problem. For an exercise i need to do the following:
Code: Select all
echo /? This is an optional parameter
But the problem is that it displays the help for echo command. I want it to display "/? This is an optional parameter".
I looked in google but couldn't find a solution. I tried with ^(the escape character), but that didn't help. So for now I do //?, but that's not a good solution =)
Grtz
Re: Echoing /?
Posted: 27 Jan 2011 00:44
by amel27
Re: Echoing /?
Posted: 27 Jan 2011 02:38
by jeb
Hi Kligam,
better use this variant
For explanations you could look at
http://www.dostips.com/forum/viewtopic.php?f=3&t=774 "ECHO. FAILS to give text or blank line - Instead use ECHO/"
hope it helps
jeb
Re: Echoing /?
Posted: 27 Jan 2011 04:53
by orange_batch
I like echo: best, source code aesthetics-wise. It kind of denotes speech like an RPG and looks along the lines of :labels and ::Comments.
Re: Echoing /?
Posted: 27 Jan 2011 17:18
by jeb
Hi orange,
why I don't use "echo:" ?
I made some speed tests.
I measure the time for 1000 times echo a "x" in a small window
Code: Select all
echo x 3500ms
echo(x 3440ms
echo:x 3510ms
echo.x 6940ms
The result: "echo " "echo(" and "echo:" seems to be equal, "echo." is really slow and it fails complete, if a file with the name "echo" exists.
But the next test fails also for the echo:
Code: Select all
echo \..\%~0 ~3500ms
echo(\..\%~0 ~3500ms
echo:\..\%~0 crash with infinite loop
echo.\..\%~0 crash with infinite loop
hope it helps
jeb
Re: Echoing /?
Posted: 29 Jan 2011 07:35
by orange_batch
Indeed, but who would ever
echo:\..\ etc?
Re: Echoing /?
Posted: 29 Jan 2011 09:04
by jeb
But if I want to use something like BatchSubstitute on a file like
Code: Select all
..\..\src\main.c
..\..\src\convert.c
Then this code would fail
for /F %%A IN (myFile.txt) DO (
set line=%%A
echo:!line!
)