Re: sleep() for half a sec?
- Posted by ghaberek (admin) Feb 17, 2015
- 1366 views
newphil82 said...
Just in case you get this problem??
I wanted to make a VERY QUICK 'blink' in a Windows GUI. Docs suggest fractions OK in 'sleep' but I got: sleep(0.5) type check failure, "t is an integer"
It looks like you're using the legacy include files.
In Euphoria 3.1, sleep() was defined in misc.e.
-- from misc.e global procedure sleep(integer t) -- go to sleep for t seconds -- allowing (on WIN32 and Linux) other processes to run if t >= 0 then machine_proc(M_SLEEP, t) end if end procedure
But starting with Euphoria 4.0, sleep() was defined in std/os.e.
-- from std/os.e public procedure sleep(atom t) -- go to sleep for t seconds -- allowing other processes to run if t >= 0 then machine_proc(M_SLEEP, t) end if end procedure
Both methods do call the same internal machine function, which is why your trick worked.
Further testing indicates that sleep() in Euphoria 4.0 does provide sub-second resolution.
include misc.e as misc include std/os.e as os atom t0, t1, t2 t0 = time() misc:sleep( 1 ) t1 = time() - t0 t0 = time() os:sleep( 0.1 ) t2 = time() - t0 printf( 1, "misc:sleep(1) = %0.1f sec\n", {t1} ) printf( 1, "os:sleep(0.1) = %0.1f sec\n", {t2} )
misc:sleep(1) = 1.0 sec os:sleep(0.1) = 0.1 sec
In short, make sure you are using the Euphoria 4.0 standard library routines in the std include directory.
-Greg