View unanswered posts | View active topics It is currently 18 Apr 2014 20:25



Post new topic Reply to topic  [ 3 posts ] 
syntax error 
Author Message

Joined: 15 Feb 2012 14:02
Posts: 163
Post syntax error
Can you help me with this?

Code:
@echo off

FOR /F %%X IN (x/list.txt) DO (

REM echo %%X
SET /A odd="%%X%%2"

if %odd%==0 echo EVEN %%X
else Echo ODD %%X
  FOR /F %%Y IN (y/list.txt) DO (
  REM echo %%Y
  SET /A odd="%%Y%%2"
  if %odd%==0 echo EVEN %%X
  else Echo ODD %%X
)
)
pause


I cannot get the conditions working.


30 May 2012 17:10
Profile

Joined: 08 Apr 2012 17:11
Posts: 187
Post Re: syntax error
Of course you can't:
Firstly, you need delayed expansion if you want to work with variable manipulation within loops.
Secondly, you didn't put the IF statements on the same line.
Code:
@echo off
setlocal enableDelayedExpansion

FOR /F %%X IN (x/list.txt) DO (

REM echo %%X
SET /A "odd=%%X %% 2"

if "!odd!"=="0" (echo EVEN %%X
) else Echo ODD %%X
  FOR /F %%Y IN (y/list.txt) DO (
  REM echo %%Y
  SET /A "odd=%%Y %% 2"
  if "!odd!"=="0" (echo EVEN %%X
  ) else Echo ODD %%X
 )
)
pause


30 May 2012 17:19
Profile WWW

Joined: 15 Feb 2012 14:02
Posts: 163
Post Re: syntax error
Thanks. I forgot about it when I spend some time with different language.


31 May 2012 00:12
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: Baidu [Spider], Google [Bot], Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.