Echoing /?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Kligham
Posts: 2
Joined: 26 Jan 2011 19:46

Echoing /?

#1 Post by Kligham » 26 Jan 2011 19:50

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

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Echoing /?

#2 Post by amel27 » 27 Jan 2011 00:44

Code: Select all

echo./?

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Echoing /?

#3 Post by jeb » 27 Jan 2011 02:38

Hi Kligam,

better use this variant

Code: Select all

echo(/?

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

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Echoing /?

#4 Post by orange_batch » 27 Jan 2011 04:53

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.

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Echoing /?

#5 Post by jeb » 27 Jan 2011 17:18

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

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Echoing /?

#6 Post by orange_batch » 29 Jan 2011 07:35

Indeed, but who would ever echo:\..\ etc? :roll:

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Echoing /?

#7 Post by jeb » 29 Jan 2011 09:04

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!
)

Post Reply