Availability | All terminals |
Description | This function starts the timeout timer. This function can be used to implement timeouts in an application. When the timer is started, EndTimer() can be used to check if the specified time has elapsed. |
Syntax | void StartTimer( unsigned int timevalue ); |
Arguments |
unsigned int timevalueThis is the time in steps of 20 milliseconds. For example, time = 50 refers to one second. |
Returns | None |
Remarks |
Use EndTimer() to check if the specified time has elapsed. Use TimerValue() to find out how much time is left before the timer elapses. The maximum timeout value that can be set is about 22 minutes (65535*20ms). |
Example |
#include <stdio.h> #include "lib.h" void main( void ) { for(;;) { printf("\nTick off 5 sec"); StartTimer( 5 * 50 ); while( !EndTimer()) { printf("\nTime left %d s", TimerValue()/50); Sound( TSTANDARD, VSTANDARD, SMEDIUM, 0); Delay( 50 ); } printf("\nDone"); ResetKey(); while( !kbhit()) Idle(); } } |