Re: questions from a newbie

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

Thys de Jong writes:
> does any one know a routine for a wait command that could be
> invoked in say milliseconds like:

You can improve the resolution of time() by setting
tick_rate(), but this only works up to about 1000 ticks/second.
Another solution can be found in Language War - sched.e.
Basically, you see how many for-loop iterations you can do in
(say) 1 second. Then, when you want to wait for a few milliseconds,
you loop for some fraction of that. Here's the code I used.

constant sample_interval = 1.0
atom sample_count

global procedure init_delay()
-- since time() does not have fine enough
-- resolution for small delays, we see how many for-loop iterations
-- we can complete over a small sample period
    atom t

    t = time() + sample_interval
    for i = 1 to 999999999 do
        if time() < t then
        else
            sample_count = i
            exit
        end if
    end for
end procedure

global procedure delay(atom t)
-- delay for t seconds
    atom stop
    if t > sample_interval then
        -- time() should be precise enough
        stop = time() + t
        while time() < stop do
        end while
    else
        -- loop a certain number of times
        stop = time() + sample_interval
        for i = 1 to floor(t / sample_interval * sample_count) do
            if time() < stop then
            else
            end if
        end for
    end if
end procedure


> in text mode any ideas how to print a character to
> row 25 column 80 without scrolling the screen????

Try wrap(0):

include graphics.e
clear_screen()
wrap(0)                      -- turn off line-wrap
position(25, 80)
puts(1, 'x')
if getc(0) then
end if


Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

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

Search



Quick Links

User menu

Not signed in.

Misc Menu