Batch file problems with IF statements and parantheses -
i trying batch start experiments. need redo of them not all. ones (s==1000 , r==0.5 , (c==1 or c==25 or c==75)) have been done ok can skipped (they take long time run). ever since introduced if statements, way parentheses parsed giving errors. keep getting unexpected ( or ). i've tried rewriting whole thing, no avail.
i know lot 'please check code bugs' question, @ wits end here.
set dotest=1 %%s in (1000,2000) ( %%r in (0.5,0.75,1) ( %%c in (1,25,75,100) ( if (%%s==1000) ( if (%%r==0.5) ( if (%%c==1) (set dotest==0) if (%%c==25) (set dotest==0) if (%%c==75) (set dotest==0) ) ) if (%%dotest==1) ( echo "hello world!" ) ) ) )
@echo off setlocal enabledelayedexpansion %%s in (1000,2000) ( %%r in (0.5,0.75,1) ( %%c in (1,25,75,100) ( set dotest=1 if %%s == 1000 ( if %%r == 0.5 ( if %%c == 1 ( set dotest=0 ) if %%c==25 ( set dotest=0 ) if %%c==75 ( set dotest=0 ) ) ) if !dotest! == 1 ( echo "hello world^!" %%s,%%r,%%c ) ) ) )
you should able run without syntax errors - there's no way me know if logic correct.the issues example:
if
conditions defined without brackets- start brackets context after if on same line
- if change dotest value within brackets , need again in brackets content you'll need delayed expansion ,
!
instead of%
- in
set
command use 1 equal sign
Comments
Post a Comment