1.

Solve : count down?

Answer»

can you make a peice of code that will count down to a picific time yes.Some years ago, another poster requested the very same THING. I have a HTML Application script that does the counting down in a window. If you wanted it posted let us know.



@echo off
Title Countdown
cls
echo Countdown! 5.
ping LOCALHOST -n 2 >nul
cls
echo Countdown! 4.
ping localhost -n 2 >nul
cls
echo Countdown! 3.
ping localhost -n 2 >nul
cls
echo Countdown! 2.
ping localhost -n 2 >nul
cls
echo Countdown! 1.
ping localhost -n 2 >nul
cls
echo Countdown! 0.
ping localhost -n 2 >nul
cls
echo Tada.
pause >nul
cls
exitcan you make a peice of code that will count down to a specific time
All you have to do is replace 5,4,3,2,1,0 with the time?I don't know, I think it will INVOLVE date arithmetic.

My guess would be to show the time remaining until a specific time, but until the OP provides further clarification who knows.Well, you could just add the set p command and all of the numbers would be variables.Quote from: BatchRocks on January 09, 2009, 05:05:52 AM

@echo off
Title Countdown
cls
echo Countdown! 5.
ping localhost -n 2 >nul
cls
echo Countdown! 4.
ping localhost -n 2 >nul
cls
echo Countdown! 3.
ping localhost -n 2 >nul
cls
echo Countdown! 2.
ping localhost -n 2 >nul
cls
echo Countdown! 1.
ping localhost -n 2 >nul
cls
echo Countdown! 0.
ping localhost -n 2 >nul
cls
echo Tada.
pause >nul
cls
exit

learn how to use loops man. All your codes could be 10x smaller if you want to count down to a specified time of day...

Code: [Select]
@echo off

rem input time as hh:mm:ss
rem use 24 hour clock
rem e.g. for 4:15 PM use 16:15:00

rem only works for a time the same day
rem does not check for nonsense time
rem e.g. earlier than now

set /p hhmmss=Start time hh:mm:ss?

set hh=%hhmmss:~0,2%
set mm=%hhmmss:~3,2%
set ss=%hhmmss:~6,2%
set stimefull=%hh%:%mm%:%ss%
if "%hh:~0,1%"=="0" set hh=%hh:~1,1%
if "%mm:~0,1%"=="0" set mm=%mm:~1,1%
if "%ss:~0,1%"=="0" set ss=%ss:~1,1%
set /a ssecs=%ss%
set /a msecs=60*%mm%
set /a hsecs=3600*%hh%
set /a startsecs=%ssecs%+%msecs%+%hsecs%

echo.
echo Waiting for time %stimefull%

:TWAIT

set ntime=%time%
set nhh=%time:~0,2%
set nmm=%time:~3,2%
set nss=%time:~6,2%
if "%nhh:~0,1%"==" " set nhh=%nhh:~1,1%
if "%nmm:~0,1%"=="0" set nmm=%nmm:~1,1%
if "%nss:~0,1%"=="0" set nss=%nss:~1,1%
set /a nssecs=%nss%
set /a nmsecs=60*%nmm%
set /a nhsecs=3600*%nhh%
set /a ntimesecs=%nssecs%+%nmsecs%+%nhsecs%
set /a timeleft=%startsecs%-%ntimesecs%
title Seconds: %timeleft%
if "%ntimesecs%" GEQ "%startsecs%" goto snow
ping localhost -n 2 >nul
goto twait

:snow


Quote from: devcom on January 09, 2009, 07:38:50 AM
Quote from: BatchRocks on January 09, 2009, 05:05:52 AM
@echo off
Title Countdown
cls
echo Countdown! 5.
ping localhost -n 2 >nul
cls
echo Countdown! 4.
ping localhost -n 2 >nul
cls
echo Countdown! 3.
ping localhost -n 2 >nul
cls
echo Countdown! 2.
ping localhost -n 2 >nul
cls
echo Countdown! 1.
ping localhost -n 2 >nul
cls
echo Countdown! 0.
ping localhost -n 2 >nul
cls
echo Tada.
pause >nul
cls
exit

learn how to use loops man. All your codes could be 10x smaller

I could say the very same to you about Classes in VB.


Discussion

No Comment Found