Date: Fri, 15 Mar 2002 16:58:27 -0500
From: Jim Witte <jswitte_at_bloomington.in.us>
> What does SetupIdle take as a parameter? The NPG say's it takes a
>delayvalue in milliseconds, but the Clock example has the line
>":SetupIdle(:viewIdleScript());" indication the path of the idle
>script. The line ":SetupIdle(0)" doesn't work, but Adam Tow's
>AlaramClock includes SetupIdle(0) in a number of places.
SetupIdle takes indeed a delay value in milliseconds. Once you called
it, the system will call viewIdleScript method of the frame (it has
to be a view and be open). viewIdleScript returns the number of
milliseconds before being called back.
Therefore, if you something to be done periodically (while the view
is open) and the first period to happen immediatly, doing :SetupIdle(
:viewIdleScript() ) is a good option.
> The main idea is to have an idle script repeatedly check the time to
>see if it's between 5 and 10 minutes after 3:15 (a reasonable bit of
>time for the 3AM house-keeping duties to get done). If it is,
>checkPower is called, which checks if it's running on ac, and will shut
>it off if it is. This is in the viewIdleScript (at bottom).
This is a way. However, if the Newton doesn't go to sleep at 3 AM, it
is because of a problem and I'm not sure you would be able to put the
Newton to sleep. Moreover, since you're not using an alarm, I'm not
sure the Newton will be waken up to run your idle script.
> The "Setup Idle Script" button in the main view sets up the idle
>script, which runs one time. But it doesn't run after that. I also
>need to know how to put the Newt to sleep (I thought there was a
>gotosleep function..)
PowerOff( 'because );
>viewIdleScript;
>func() begin
> timeArray := self:GetTimeArray();
> tHour := timeArray[0];
> tMin := timeArray[1];
>
> print("Idling"); // debug
> //self:SetTimeFlds();
> //print( :checkTime(tHour, tMin) );
>
> if :checkTime(tHour, tMin) then
> begin
> self:checkPower();
> return kAlmostDayMilliseconds; // (1440 min/day -
>10)*60*1000 ms
> end;
> else
> return idleDelay; // set to 100 ms as a test
You need to be sure that your view is open, otherwise the idler
object is killed.
I don't really understand what your checkPower method does.
Additionally, you probably want to sleep until next day, 3 AM and not
for one day (it will be less the first time you run it).
Paul
-- Home page: http://www.kallisys.com/ Newton-powered WebServer: http://newton.kallisys.net:8080/-- Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html Read the Newton FAQ: http://www.guns-media.com/mirrors/newton/faq/ This is the NewtonTalk mailing list - http://www.newtontalk.net
This archive was generated by hypermail 2.1.2 : Tue Apr 02 2002 - 14:02:57 EST