DosTips.com

A Forum all about DOS Batch
It is currently 13 Feb 2016 04:48

All times are UTC-06:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: syntax error
PostPosted: 30 May 2012 17:10 
Offline

Joined: 15 Feb 2012 14:02
Posts: 163
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.


Top
   
 Post subject: Re: syntax error
PostPosted: 30 May 2012 17:19 
Offline

Joined: 08 Apr 2012 17:11
Posts: 187
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


Top
   
 Post subject: Re: syntax error
PostPosted: 31 May 2012 00:12 
Offline

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot] and 6 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® Forum Software © phpBB Limited