Re: getting the timing right
Re: getting the timing right
- Subject: Re: getting the timing right
- From: "Geoff Graham" <email@hidden>
- Date: Sat, 9 Dec 2000 07:59:29 -0600
At 10:19 PM -0800 12/8/00, "Patrick S. Page-McCaw" <email@hidden> wrote:
>
I suspect that idle does
>
not expect to be called at such quick and precise intervals. Or I'm doing
>
something wrong.
I suspect you are right about the idle handler. I didn't absorb your script, but if Script Editor does it right and the shell doesn't, I don't think your coding is the issue. Try Dialog Director <
http://www.hylight.demon.co.uk>. it uses ticks (1/60 second) in a repeat loop and is pretty accurate. You'll need to download it and play with it to get your dialog looking right, but it's not as hard as it may look at first. Here's the idea:
--script
set taptimes to 50
set tapwait to 30 -- ticks
set going to false
-- the dialog box record
set dlog to ,
{bounds:[50, 50, 360, 162], style:standard window, closeable:true, name:"Tapping", contents:[,
{class:push button, bounds:[10, 80, 70, 100], name:"Start"}, ,
{class:gauge, bounds:[50, 30, 250, 42], max value:taptimes}, ,
{class:static text, bounds:[6, 4, 118, 24], contents:"Count"}, ,
{class:static text, bounds:[122, 4, 236, 24], contents:"" & tapwait & " ticks"}, ,
{class:static text, bounds:[238, 4, 352, 24], contents:"Fish"} ,
]}
set a to 0
dd install with grayscale
set d1 to dd make dialog dlog
repeat
set ui to dd interact with user for max ticks tapwait
if ui = -1 then -- close window
exit repeat
else if ui = 1 then -- Start / Stop
if going then
set tapwait to 6000 -- no need to suck cycles
dd set name of item 1 of d1 to "Start"
set going to not going
set a to 0
else
set tapwait to 30 -- get ready
dd set name of item 1 of d1 to "Stop"
set going to not going
end if
else if ui = null then -- max ticks has expired
if going then
TaptheGlass()
set a to a + 1
dd set value of item 2 of d1 to a
dd set contents of item 3 of d1 to a
end if
end if
end repeat
dd uninstall
on TaptheGlass()
beep 1
end TaptheGlass
-- end script
the dlog record will probably wrap on you, and it's full of continuation characters that will get commaed. Let us know how smart fish really are.
geoff