|
Answer» Hi,
I need to echo the following message to screen in MS-DOS where setlocal enabledelayedexpansion is declared.
"The mail was successfully SENT!"
This is proving difficult because of the escape CHARACTERS used. Using ECHO The mail was successfully sent^^! shows the exclamation mark but not when ENCLOSED in quotation marks, as this shows as "The mail was successfully sent^".
Any ideas? Code: [Select]@echo off set var=! setlocal EnableExtensions EnableDelayedExpansion echo "The mail was successfully sent!var!" pauseThanks :-)THis works for me, with just one escape character
@echo off setlocal enabledelayedexpansion echo "The mail was successfully sent^!" pause
result
C:\>echo_exclamation.bat "The mail was successfully sent!" Press any key to continue . . .
Why not just toggle delayed EXPANSION off before the echo and back on after the echo.Quote from: Squashman on October 31, 2012, 05:32:46 PM Why not just toggle delayed expansion off before the echo and back on after the echo.
If you're using variables with setlocal enabled, then those variables WOULD be wiped out once you did that. Too many people use an exclamation mark as if it was a period. That's true!!
|