home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
153_01
/
pause.c
< prev
next >
Wrap
Text File
|
1985-03-10
|
2KB
|
46 lines
/* *** pause.c *** */
/* */
/* IBM-PC microsoft "C" under PC-DOS */
/* */
/* Function to cause a program to appear to pause for a given period */
/* time. Uses the system clock for timing. Accurate to 1/100's of */
/* a second. */
/* */
/* Written by L. Cuthbertson, May 1984. */
/* */
/*********************************************************************/
/* */
pause(seconds)
float seconds; /* number of seconds to pause */
{
int ih,im,is,iths;
long current,offset,diff;
/* determine the current time */
dostime(&ih,&im,&is,&iths);
/* calculate the current time in 1/100's of a second */
offset = (ih*360000) + (im*6000) + (is*100) + iths;
current = offset;
/* calculate the number of 1/100's of a second to pause */
diff = seconds*100;
if (diff > 8640000) { /* maximum of 1 day pause */
return(-1);
}
/* keep on polling the clock until difference has elapsed */
while ((current-offset) < diff) {
dostime(&ih,&im,&is,&iths);
current = (ih*360000) + (im*6000) + (is*100) + iths;
if (current < offset) { /* spans midnight */
current += 8640000;
}
}
/* done */
return(0);
}
eri