Re: questions from a newbie
- Posted by Al Getz <xaxo at AOL.COM> Jan 03, 1999
- 490 views
>does anyone know a routine for a wait command that could be >invoked in say milliseconds like: >wait(500) or delay(500) ??? If you use the Windows95/98 API you can use the C function: DWORD GetTickCount(VOID) which returns the number of milliseconds since Windows started. Then set up a differencing routine to determine the milliseconds that have past since a given point in the program. After loading Win's kernal32.dll and linking GetTickCount (or GetTickCountA) as a function: --declare and initialize variables: atom t001,t002,milliseconds,MilliTime t001=0 --function setup: function GetTicks() t002=c_func(GetTickCount,{}) milliseconds=t002-t001 t001=t002 return milliseconds end function MilliTime=GetTicks() --now every call to 'GetTicks()' returns the time in milliseconds --since the last call to 'GetTicks()'. --example: MilliTime=GetTicks() CallTestRoutine() MilliTime=GetTicks() --now MilliTime is the number of milliseconds between calls. --end example. One thing should be pointed out here though: With any of the timing methods there could be a wide variance in the time it takes to execute the entire "TestRoutine" as Windows has a lot to keep up with sometimes and not other times depending on all the activities going on at the time the test routine is executed. Remember it's a multitasking environment. Expect as much as 100% change or more depending on tasks. Of course this implies there is no way any critical timing loops can be constructed with any timing method except in assembly language. You might also try using the timer functions present in the API which are all called quite easily from Euphoria but again the accuracy can't be mistaken for perfect. One last note is that some of the timing routines in Windows are rumored to start over around the year 2037. Instead of returning the number of seconds since a given year in the past it will start returning the number of seconds since 2037. This is because of the max integer count capability using 4 bytes. Hey good luck with all your programs!! I'll be looking forward to seeing some great software from you in the future. Xaxo at AOL.COM