timer with progress bar?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, kevinmiller

Post Reply
no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Fri Aug 02, 2013 12:14 am

timer with progress bar?

Post by no1g8tor96 » Sat Aug 04, 2018 5:41 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2220
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: timer with progress bar?

Post by jmburnod » Sat Aug 04, 2018 6:12 pm

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

capellan
Posts: 492
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

Re: timer with progress bar?

Post by capellan » Sat Aug 04, 2018 8:44 pm

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

no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 16
Joined: Fri Aug 02, 2013 12:14 am

Re: timer with progress bar?

Post by no1g8tor96 » Wed Aug 08, 2018 3:30 am

Thanks so much for the help. I got the project done thanks to all of your help and I really appreciate it.

Mike

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”