Jon wrote:

I'm trying to schedule something to happen some time in the future. Due to some other complexities, I cannot just do a

send "mouseUp" to me in 1000 seconds

Rather, I have to wake up every 10 seconds and figure out whether it is time to do the processing or not. The current code is presented below.

The interesting thing is that, despite the claim that Rev times are in seconds, and even in milliseconds, the values I'm seeing are in increments of 60 seconds. I flagged a line in the code below. Rather than seeing "60" and then "50" and then "40", etc, I instead see "60" 6 times and then "0". Am I doing something wrong? Or, rather, what am I doing wrong?

Yes :-)
Not entirely sure - there may be multiple things ...

BTW: feel free to show me how I should have written this: it is hugely awkward and could be done much easier in languages that I know better.

:)

Jon


on mouseup
  local mostRecentFTPTime
  -- is it time yet?
  convert the date && the time to dateItems
  subtract field "TestFreq" from item 5 of it
  convert it to seconds
  put item 1 of it into currTime
  if currTime < mostRecentFTPTime then
     -- show the user how long before next test
set the text of field "TimeToGo" to mostRecentFTPTime - currTime & " secs to go" -- this is the line I'm talking about
     send "mouseUp" to me in 10 seconds
     exit mouseUp               end if

 --  do the FTP stuff here!

  convert the date && the time to seconds
  put it into mostRecentFTPTime
  send "mouseUp" to me in 10 seconds
end MouseUp

1. I *think* you want the declaration of mostRecentFTPTime to be outside the handler. A local declared inside handler gives you a "handler-local" variable - which is reset each time you enter the handler. A local declared outside any handler is a "script-local" variable, and retains its value between calls.

2. Unless you need to for some reason I don't see here, don't mess around with date & time.

Does "TestFreq" change ? If not, I'd do something like the following :

local  nextFTPTime
on mouseUp
  if the seconds > nextFTPTime then
     do ftp Stuff
     put the seconds + field "TestFreq" into nextFTPTime
  end if
  send "mouseUp" to me in 10 seconds
end mouseUp

or if you want to monitor it, replace the "end if" by

    else
put nextFTPTime - the seconds & "seconds to go" into field "TimeToGo"
    end if


If TestFreq does vary, then you need to do more like

local mostRecentFTPTime
on mouseUp
   if the seconds > mostRecentFTPTime + field "TestFreq" then
      do ftp Stuff
      put the seconds into mostRecentFTPTime
   end if
  send "mouseUp" to me in 10 seconds
end mouseUp


--
Alex Tweedly       http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.12/77 - Release Date: 18/08/2005

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to