Home All Groups Group Topic Archive Search About


Author
7 Mar 2007 3:27 PM
doubleJ
Hello...
Here's the script that I'm testing.

setlocal enabledelayedexpansion
for /f "tokens=1,2,3 delims=/" %%i in ("%date:~4%") do (set yfm=%%i)
goto :eof

Now, here's the output.  Notice that the variable yfm isn't getting updated.

C:\Working>test.bat
C:\Working>setlocal enabledelayedexpansion
C:\Working>for /F "tokens=1,2,3 delims=/" %i in ("03/07/2007") do (set
yfm=%i )
C:\Working>(set yfm=03 )
C:\Working>goto :eof
C:\Working>echo %yfm%
03/07/2007
C:\Working>

Is there any reason why !yfm! wouldn't be updating?  It should be "03" when
echo'd.
JJ

Author
8 Mar 2007 10:38 PM
Tom Lavedas
On Mar 7, 10:27 am, doubleJ <doub***@discussions.microsoft.com> wrote:
Show quote
> Hello...
> Here's the script that I'm testing.
>
> setlocal enabledelayedexpansion
> for /f "tokens=1,2,3 delims=/" %%i in ("%date:~4%") do (set yfm=%%i)
> goto :eof
>
> Now, here's the output.  Notice that the variable yfm isn't getting updated.
>
> C:\Working>test.bat
> C:\Working>setlocal enabledelayedexpansion
> C:\Working>for /F "tokens=1,2,3 delims=/" %i in ("03/07/2007") do (set
> yfm=%i )
> C:\Working>(set yfm=03 )
> C:\Working>goto :eof
> C:\Working>echo %yfm%
> 03/07/2007
> C:\Working>
>
> Is there any reason why !yfm! wouldn't be updating?  It should be "03" when
> echo'd.
> JJ

That's peculiar, 'cause it works as expected for me (XP SP2).

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh
Author
9 Mar 2007 6:27 AM
doubleJ
I know it's peculiar, that's why I posted.
Hehehe...
I'm using xp sp2, as well.
JJ

Show quote
"Tom Lavedas" wrote:

> That's peculiar, 'cause it works as expected for me (XP SP2).
Author
9 Mar 2007 1:36 PM
Tom Lavedas
On Mar 9, 1:27 am, doubleJ <doub***@discussions.microsoft.com> wrote:
> I know it's peculiar, that's why I posted.
> Hehehe...
> I'm using xp sp2, as well.
> JJ
>
> "Tom Lavedas" wrote:
> > That's peculiar, 'cause it works as expected for me (XP SP2).

Okay, so my guess is that your posted example is not the exact
condition that is creating the error.  Rather, it is an extract from a
larger procedure such that the real problem is created by some other
aspect of that larger procedure.  I say that for two reasons: first
the setlocal statement is not applicable in the example you posted and
the second is that the output you posted has an ECHO statement not
shown in the example.

I think you're going to need to post a complete example that exactly
creates your problem.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

AddThis Social Bookmark Button