Re: sleep() standard function

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Peterson wrote:
> 
> The sleep function included with Euphoria can only handle integer values.
> 
> Simply changing integer to atom in the function definition allows it to handle
> fractional values as well.  
> 
> Rob, d'you think you could change this for 3.0?  
> Thus saving anyone who needs to use fractional times the time of manually
> changing
> it.
> 
> Jeremy

I agree. I ran into this problem recently too. In the meantime I've been using
this procedure:

-- Waits for a specific amount of time passed to it in seconds
global procedure wait(atom seconds)
    atom start_time

    start_time = time()

    if integer(seconds) then
        sleep(seconds)
    else -- a floating point number
        while time() - start_time < seconds do -- Nothing
            -- Busy loop until `seconds` have elapsed
        end while
    end if

end procedure  -- wait

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu