i have code:
:set @echo %random%%random%%random%%random%%random%%random%%random%%random%%random% goto :set but how make runs few seconds? , how change variable?
i %time% current time , parsed current second. did on each iteration of loop. if desired time has not spent on loop, (defined loopduration) continue next iteration.
echo off :: set loop duration set /a loopduration=2 :: starting second set "startingtime=%time:~6,2%" set /a startingtime=%startingtime% :set echo %random%%random%%random%%random%%random%%random%%random%%random%%random% :: current second set "currenttime=%time:~6,2%" set /a currenttime=%currenttime% if %currenttime% lss %startingtime% ( set /a currenttime=%currenttime% += 60 ) set /a timepassed=%currenttime%-%startingtime% :: if desired time has not passed, continue loop if not %timepassed% equ %loopduration% (goto :set) edit:
i checked special case here stephan. in case, if startingtime has value of 59 or close 60, currenttime have value less startingtime. checked simple if statement:
if %currenttime% lss %startingtime% ( set /a currenttime=%currenttime%+=60 ) so there no possibility currenttime less startingtime. unless want loop run more 59 seconds.
Comments
Post a Comment