|
Answer» I wrote a little batch file (OS=XP) that just counts from 1-4, in increments of +1, each time the batch file is run. It counts fine, except it doesn't stop at 4, but keeps counting indefinitely. I think the problem might be in the SECOND IF statement. Either: (a) the condition is not reading the number, and/or (b) the command to reset the number to 0 is not working. I can't get the syntax of this line right or something?: ---------------------- @ echo off echo %number% <--(just a checker) If EXIST ZZtrash.bat call ZZtrash
If "%number%"=="4" set number=0
echo %number% <--(just a before-checker ) set /a number=number+1 echo %number% <--(just an after-checker ) echo set number=%number% >ZZtrash.bat pause ---------------------- Any HELP here would sure be appreciated! ZonerZone for counting, you can use for loop to loop through a range of numbers.see here for exampleHere's ONE i made a while back. I edited the CODE so it will stop at four.
Code: [Select]@echo off color f0 cls echo. echo. Please enter the starting number. set a=0 cls set /a b=%a%-1 :1 cls set /a b=%b%+1 if /i %b% EQU 4 ( echo. echo.The Number is now FOUR echo. pause exit ) echo. echo. %b% echo. echo.Keep pressing any key. . . pause > nul goto :1
|