Re: [NTLK] Programatically setup a countdown

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Thu May 13 2004 - 23:03:41 PDT


Aux environs du 13/05/04 à 22:21 -0500, sous le titre "[NTLK]
Programatically setup a countdown", Jack Burks prit sa plus belle
plume pour écrire les mots suivants:
>So how would one go about setting up a countdown (so as to allow a timer to
>continuously move from one second to the next) to start at a specific number
>and stop any action when the count reaches zero. I'm working on a text game
>for the Newton and want to implement a timer to actually setup a sense of a
>real game. I'm fairly certain that you would have to use Ticks, but I'm not
>completely certain.

There are two ways to use timers in NewtonScript.
One is AddDelayedSend/AddDelayedCall. The drawback of these is that
there is no way to stop them.

The other is ViewIdleScript. You can stop the timer (it will be
stopped automatically if the view is closed).

Be aware that the timers work by using a feature of the kernel that
is send an message to a port in the future. The NewtonScript task
(AppWorld) will only get it if it's idle waiting for events. This
means that:
- you need to give CPU back if you want to be called back.
- you have no warranty that the callback arrived exactly when you
asked it. It may be later.

Both methods are fairly well documented in the Programmer's Guide and
the Programmer's Reference manuals. Don't hesitate to let me know if
you have any problem.

If this event-based scheme doesn't suit you and you want to draw
batteries, you can still fork a new task. I just don't suggest this.
Still, you'll find a document explaining how to do it here:
http://www.kallisys.com/newton/bowels/

(Scroll down to Forks in NewtonScript).

Paul

-- 
Philosophie de baignoire - consultations sur rendez-vous.
NPDS/NewtonOS: http://newton.kallisys.net:8080/
Apache/FreeBSD: http://www.kallisys.com/
-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
Official Newton FAQ: http://www.chuma.org/newton/faq/
WikiWikiNewt for all kinds of articles: http://tools.unna.org/wikiwikinewt/


This archive was generated by hypermail 2.1.5 : Thu May 13 2004 - 23:30:01 PDT