Getting into LiveCode for iOS? Ask your questions here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sat May 16, 2015 11:47 pm
Hi L.Coder
Creating a 'resume' functionality depends on how you coded the 'pause' - so can you share your code?
Kind regards
Dave
EDIT: and also depends on your timer code so can you share that too?
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Sun May 17, 2015 1:05 am
Of Curse, first is the code of the timer and then is the pause.
thanks a lot Dave, I hope that you can help me.
Code: Select all
on mouseUp
put fld “timerDisplay"into CountTimer
put CountTimer into fld "timerDisplay"
send "UpdateTimer" to me in 1 second
end mouseUp
on UpdateWork
subtract 1 from CountTimer
put CountTimer into fld "timerDisplay"
if CountTimer>0 then
send "UpdateWork" to me in 1 second
else
wait 0.3 seconds
send "UpdateRest" to me in 1 second
end if
end UpdateWork
Code: Select all
on mouseUp
if the visible of me is true then
repeat for each line i in the pendingMessages
cancel (item 1 of i)
end repeat
end if
end mouseUp
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun May 17, 2015 11:57 am
Hi l.coder
One of the nice things about a great coding tool like LiveCode is that there are so many different ways to 'skin a cat' - and how you write a solution to a task in the morning might be different to how you write it in the evening ... here is a solid and clunky (but easy to grasp!) way to handle pause and resume:
Code: Select all
local sCounter,sPaused
on startCounter
put empty into sPaused
put 10 into sCounter
put sCounter && "seconds remaining" into fld "fldTimerDisplay"
send runCounter to me in 1 second
end startCounter
on runCounter
if sPaused is empty then
if sCounter > 1 then
subtract 1 from sCounter
put sCounter && "seconds remaining" into fld "fldTimerDisplay"
send runCounter to me in 1 second
else
put "Time's up!" into fld "fldTimerDisplay"
end if
end if
end runCounter
on pauseCounter
put true into sPaused
end pauseCounter
on resumeCounter
put empty into sPaused
send runCounter to me in 1 second
end resumeCounter
All the code should go in your card and relevant buttons only have to call the startCounter, runCounter, pauseCounter and resumeCounter handlers. Again this is just how I wrote it to show the technique of using 'send in time' together with control of script local variables (sCounter and sPaused)
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Sun May 17, 2015 9:19 pm
Thanks a lot Dave! I did it, but when I press the button puts "seconds remaining" in the fld. And I don´t know why

I´m too lost.
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun May 17, 2015 9:32 pm
Hi l.coder - can you describe what you did, what buttons and fields you have, what handlers they are calling, what code you have inside those handlers - and lastly can you describe how you think the system SHOULD be working and exactly WHERE it is breaking down
The reason I'm asking you for these things is that it may well be that writing all these descriptions will lead to enlightenment!
Good luck!
Dave
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Sun May 17, 2015 10:04 pm
Yes, sure.
Here is the code of the play
Code: Select all
local CountTimer
local CountRest
local Repeat_Times
local UpdateRest
local UpdateWork
local Opciones
on mouseUp
put 30 into CountTimer
put 20 into CountRest
put CountTimer into fld "tTimer"
put CountRest into fld "tClock"
send "UpdateCount1" to me in 1 second
end mouseUp
on UpdateCount2
subtract 1 from CountRest
put CountRest into fld "tRest"
if CountRest>0 then
send "UpdateRest" to me in 1 second
else
exit UpdateRest
end if
end UpdateCount2
on UpdateCount1
subtract 1 from CountTimer
put CountTimer into fld "tWork"
if CountTimer>0 then
send "UpdateCount1" to me in 1 second
else
wait 0.3 seconds
send "UpdateCount2" to me in 1 second
end if
end UpdateCount1
Here is my pause code:
Code: Select all
local VariableStart
on mouseUp
put true into VariableStart
if the visible of me is true then
repeat for each line i in the pendingMessages
cancel (item 1 of i)
end repeat
end if
end mouseUp
I deleted my resume code, because i tried to fix it but I only made it worse.
There are 2 timers, you can see that when the first one ends the other starts.
What I want to do is that if I press pause, the procedure stops but if I press resume continue as normal.
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun May 17, 2015 10:09 pm
hi l.coder - did you try out the code I uploaded for you? Did the pause and resume work for you? can you see why it worked and why deleting the pendingmessages (at least the way you are doing it) won't allow a resume?
Kind regards
Dave
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Mon May 18, 2015 9:28 pm
Hi Dave, Yes I did it in a new stack.
I copied & pasted it to prove, and happened what I told you:when I press the button appears "seconds remaining".
Do you know another way to do this? I tried basicly all that I know but maybe It´s not enough.
P.S Thanks a lot for help me.
Regards.
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Mon May 18, 2015 10:09 pm
Hi l.coder - try the attached stack (which has the same code as I posted earlier...)
Kind regards
Dave
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Tue May 19, 2015 3:10 am
Hi Dave, Thanks a Lot! really. You helped me a lot, I solved the problem so well, (actually you did it).
Best Regards and thanks again.

-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Tue May 19, 2015 3:51 am
Great news!
For the benefit of others on the forum can you tell us what the 'aha' moment was and/or what advice you would give for the future?
Kind regards
Dave
"...this is not the code you are looking for..."
-
L.Coder
- Posts: 15
- Joined: Mon May 04, 2015 12:34 am
Post
by L.Coder » Thu May 21, 2015 10:05 pm
The variable helps me a lot & one advice will be: READ AND STUDY THE CODE As much as you can.
Thank you again Dave.