Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
einstein1969
- Expert
- Posts: 976
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
#1
Post
by einstein1969 » 23 May 2014 04:21
Hi,
I have the necessity to use the percent expand in a SET with the unary operator "!"
I have tried in this mode but not work. I prefer not use the toggle to disabledelayedexpansion, primarly for performance problem.
It is possible?
Code: Select all
@echo off
setlocal disabledelayedexpansion
set "E=!!"
setlocal enabledelayedexpansion
(
set /a "a=!E!10"
set /a "b=%E%10"
)
echo !a! !b!
result:
einstein1969
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#2
Post
by penpen » 23 May 2014 05:14
If you are not allowed to just escape the '!', then you might do it this way:
@echo off
setlocal disabledelayedexpansion
set "E=!"
setlocal enableDelayedExpansion
(
set "a=1"
set /A "b=^!1"
set /A "c=!E!1"
echo(!a!, !b!, !c!
)
endlocal
penpen
-
jeb
- Expert
- Posts: 1063
- Joined: 30 Aug 2007 08:05
- Location: Germany, Bochum
#3
Post
by jeb » 23 May 2014 05:45
Instant extension should work
jeb
-
einstein1969
- Expert
- Posts: 976
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
#4
Post
by einstein1969 » 23 May 2014 09:57
Thanks penpen and Thanks Jeb.
Work like charm.
I don't probe the simple caret escape!
einstein1969