Page 1 of 1

set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 00:46
by Ed Dyreen
this works:
set "$VAR=^!$VAR:*¦=^!"

this doesn't:
set "$VAR=^!$VAR:*==^!"

this works again:
for /f "tokens=1,2* delims==" %%a in ( 'set $VAR' ) do echo.tokens=%%b_ %\n2%

Is it possible to make it work without for ?

Re: set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 01:50
by orange_batch
How is this? Sorry I can't test it right now.

Code: Select all

set $VAR=^!$VAR:*=^=^!

Re: set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 02:11
by Ed Dyreen
Ok so in the above I was trying it in a macro but I can't even make it work outside a macro, even this don't work: :?
set "$?=hello=there"
set $var=%$?:*==%
echo.$var=%$var%_
pause
exit

result:
==%
not expected at this time.

neither does this:
set $var=%$?:*^==% rem this evaluates to set "$var=hello=there"
or this:
set $var=%$?:*=^=%

Re: set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 04:01
by zia
I have problem with this script if any one of you people have the solution are welcome
In this below script i want that script after substracting 1 from day the day should desplay the result in double figure like 01..........09. this work fine when today date is in double figure. Sorry for my poor english.

SETLOCAL

REM *********** SET Value from DATE *************
set yy=%date:~-4%
set dd=%date:~-7,2%
set mm=%date:~-10,2%

set /a dd =%dd%-1

cd\
e:
cd e:\Archived-Repo\%yy%-%mm%-%dd%

My personal id is ziauktk84@yahoo.com any suggestion from any body are welcome

Re: set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 06:59
by dbenham
Hi Ed,

Isn't this a special case relevant to How to replace "=","*", ":" in a variable - a topic you already visited?

Your FOR solution will not give the correct answer for a string like "part1==part2". The correct answer is "=part2" and the FOR technique returns "part2". I think a variation of what amel27 does in the above link could be developed to give the exact solution.

One other suggestion - We are still learning the ins and outs of macros, and they are not used by the general audience. So before posting questions related to macro development code, you should probably see if the question can be distilled to its fundamentals without any unnecessary macro "baggage". In this case you managed to do that by your 2nd post. (It sounds like I don't like macros - but you know I do!)

Dave Benham

Re: set "$VAR=^!$VAR:*==^!" not working

Posted: 02 Jun 2011 07:10
by Ed Dyreen
Hmmm, I understand it know, ... guess I owe u again :wink: