Page 1 of 1

timer/counter question

Posted: Wed Jul 25, 2007 1:59 am
by homer
hello

I will try to explain:

field 1 = units
field 2 = duration
field 3 = increments
field 4 = results

button1

and something like:

on mouseUp
get field 1
get field 2
put (field1/field2)*field3 into field 3
repeat until someother mouseUp thing
end mouseUp

ok, i know it's not correct, here's the concept:

suppose i want to simulate a speedometer
field one is miles
field two is time (as in per hour)
field three increases over time and shows how many miles travelled

the slider would simulate a gas pedal
the process would continue to run as long as a button is not clicked
when a "disable" button is pressed the process stops. when the "disable" button is clicked again the process starts again.

ok... so i need something that contiunues until some other action is taken.

what i have tried so far gets me into a 'loop' i can't get out of and i have to force quit Rev application.

any suggestion or example would be appreciated.

thanks

homer

Posted: Wed Jul 25, 2007 10:02 am
by Mark
Dear Homer,

You are looking for code similar to the scripts below. I'm posting an untested example, which only looks like what you need but you will have to adjust it yourself.

Code: Select all

local lUnits,lInterval,lSomething

on mouseUp
  if lUnits is empty then
    -- initialize
    put fld 1 into lUnits
    put fld 3 into lInterval
    put fld 4 into lSomething
  end if
  if the hilite of me is false then
    set the hilite of me to true
    goCounting
  else set the hilite of me to false
end mouseUp

on goCounting
  if the hilite of me is true then
    put timer() into fld 5
    send "goCounting" to me in lInterval millisecs -- or secs?
  end if
end goCounting

function timer
  -- we could put the following 2 lines together
  put the thumbPos of scrollbar 1 into myIncrement
  return (lUnits*myIncrement/lSomething)
end timer
Best,

Mark

Posted: Wed Jul 25, 2007 6:19 pm
by homer
thanks much

I'll give this a try. Just seeing some code gives me a hint of what I need to do.

regards,

homer