MSC delay() routine?

Julian ANIGBOGU anigbogu at loria.crin.fr
Wed Mar 14 21:45:51 AEST 1990


In article <1990Mar13.041457.17217 at cubmol.bio.columbia.edu> ping at cubmol.bio.columbia.edu (Shiping Zhang) writes:
>In article <1280001 at hpcc01.HP.COM> azarian at hpcc01.HP.COM (Randy Azarian) writes:
>>Does anyone have a delay routine written in C?
[deleted]
>>  struct dostime_t time1, time2;
>[...]
>>  _dos_gettime(&time1); time2=time1;
>                         ^^^^^^^^^^^
>You can't assign a struct like that. You must assign the elements
>of a struct individually.
>
>
>-ping

You can perfectly and legally assign structs as long as they have the
same type as above. time1 and time2 are both of type dostime_t;

About the original question, how about defining a macro or a function
which takes as input the sleep time required in seconds, calls 'time'
the first time to deliver the current time and then looping with calls
to 'difftime' and 'time' until the sleep time is passed. Of course,
this is approximative but wouldn't matter too much if the sleep time
is big.

time_t ovalue,nvalue;

time(&ovalue);
while(difftime((nvalue = time( (time_t *) 0)), ovalue) < sleeptime) continue;

I hope that this helps, although I haven't tried it, it looks logical
unless ... Note that 'difftime' returns type double, so you have to
either pass sleeptime as double or cast it to double in above
statement. In any case, I know the dos gurus would have a neat
solution to your problem. 

Julian


-- 
				---------------------------------------
e-mail:	anigbogu at loria.crin.fr 	| All opinions expressed here are      |
				|  naturally mine. However ...         |
				----------------------------------------



More information about the Comp.lang.c mailing list