Page 1 of 1

timer with progress bar?

Posted: Sat Aug 04, 2018 5:41 pm
by no1g8tor96
I was hoping you could help me with timers?

I have a process thats already programmed and works perfect but I need to put in a timer that populates every 20 seconds. I know how to do using the wait statement but I need a stop button to interrupt this event.

Basically all the statements I have automated using repeat with but need to press a button to stop the process.

Repeat with x = 1 to 100
Do someting
wait 20 seconds

--- need interrupt here before next loop!!!!!!!!!!!!!
end Repeat

Thanks so much in advance for your help.

Mike

Re: timer with progress bar?

Posted: Sat Aug 04, 2018 6:12 pm
by jmburnod
Hi Mike,
You may use send command, a pendingmessage.
Something like that:

Code: Select all

on mouseUp
   send "doMyMessage" to me in 20 seconds
end mouseUp

on doMyMessage
   if the mouse is down then exit doMyMessage
   send "doMyMessage" to me in 20  seconds
   put the seconds
end doMyMessage
Please check "send" and "pendingmessage" in dictionary

For progressbar you need a startvalue and an endValue

Edit:
You may also use "wait 20 seconds with messages". In this case you get others messages

Code: Select all

on mouseup
   Repeat with x = 1 to 100
      if the mouse is down then exit repeat
      put the seconds
      wait 20 seconds with messages
   end Repeat
end mouseup
Best regards
Jean-Marc

Re: timer with progress bar?

Posted: Sat Aug 04, 2018 8:44 pm
by capellan
This works fine too:

First, create a hilite button and set the name of it to "stop handler"

Second, create a default button and set the script of it to:

Code: Select all

on mouseUp
   Repeat with x = 1 to 100
put the ticks && x
wait 1 seconds with messages
if the hilite of button "stop handler" then exit to top
--- need interrupt here before next loop!!!!!!!!!!!!!
end Repeat

end mouseUp

Now, click the button and watch the message box.
You could stop the counter just clicking the hilite button.

Al

Re: timer with progress bar?

Posted: Wed Aug 08, 2018 3:30 am
by no1g8tor96
Thanks so much for the help. I got the project done thanks to all of your help and I really appreciate it.

Mike