1.

Solve : display an exclamation mark?

Answer»

Hello there,
Just new on this forum. Hope I can find some help.
I would like to display an exclamation mark in a batch script but can't get through the problem.
Look at the following log and see if you can help me:
Code: [Select]C:\>type test1.cmd
@echo 75% discount!
C:\>test1.cmd
75 discount
C:\>type test2.cmd
@echo 75%% discount!!
C:\>test2.cmd
75% discountThanks in advance
Santiago
The problem is that both the % and ! are 'special'

Try prefixing them with ^
eg
echo 75^% discount^!

not tested, you will need to try it our
GrahamHi gpl,
Thx for your participation. Unfortunately, I forgot to mention that I tried that before.
And maybe you've not read it all, but I know how to display a percent sign (it's in the log).
Here are my guess:
Code: [Select]C:\>type test1.cmd
@echo 75% discount!
C:\>test1.cmd
75 discount
C:\>type test2.cmd
@echo 75%% discount!!
C:\>test2.cmd
75% discount
C:\>type test3.cmd
@echo 75^% discount^!
C:\>test3.cmd
75 discount75^% discount^! ?

Again, not tested.Check the shortcut that opens the command prompt for any parameters. Normally delayed expansion is off by default so the exclamation point should not be interpreted as any thing but an exclamation point.

The echo command is reasonably transparent however percent SYMBOLS should be doubled up to be interpreted correctly.

Code: [Select]echo 75%% discount!

C:\Temp>type test1.cmd
echo 75%% discount!
C:\Temp>test1.cmd

C:\Temp>echo 75% discount!
75% discount!

Good luck.

Thanks Carbon Dudeoxide,
Your idea was already tested in my previous post.

Thanks Sidewinder,
You're right about delayed expansion but the problem is obviously that I need it activated.

Anyway, I finally FOUND the correct answer. I LET you COUNT the carret SIGNS!
Code: [Select]C:\>ECHO @ECHO 75%% discount^^^^^^^^!> test4.cmd
C:\>type test4.cmd
@ECHO 75%% discount^^!
C:\>test4.cmd
75% discount!



Discussion

No Comment Found