Sample Timer Scripts
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Sample Timer Scripts
Being a complete beginner here I am wondering if anyone has a timer script built that will start a timer at a user supplied time, run at user supplied intervals and stop at a user supplied end time. I guess I could sit down and program this but thought I would ask if someone has already done something like this. It definitely would be a great time saver for me. The other thing that came to mind is to ask if there any resources that I could search for pre-written scripts.
Re: Sample Timer Scripts
You are absolutely correct. You should do this yourself. Once you get started, you will find continuous and specific help with all your issues.
Get going, and write back. Check out the "seconds" function, and its "see also" stuff, the "dateItems" keyword and its "see also", especially "convert".
Start with a repeat loop and test the seconds. Make sure you can get out of the loop.
Craig Newman
Get going, and write back. Check out the "seconds" function, and its "see also" stuff, the "dateItems" keyword and its "see also", especially "convert".
Start with a repeat loop and test the seconds. Make sure you can get out of the loop.
Craig Newman
Re: Sample Timer Scripts
Agree with Craig in that you should try this yourself. Yes, it's something that everyone does and it would be simple to post some code that does this, but I think the process of your trying this out and posting questions when it doesn't work and then finally "getting it" will be the greatest time saver in the long run.
Hint:
In particular, check out the "send xxx in nn seconds" command.
Hint:
In particular, check out the "send xxx in nn seconds" command.
Re: Sample Timer Scripts
Hi,
And also the pendingmessages function
Best
Jean-Marc
And also the pendingmessages function
Best
Jean-Marc
https://alternatic.ch
Re: Sample Timer Scripts
Hi gwildbur,
please check these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
please check these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: Sample Timer Scripts
Hi gwildbur,
if you are looking for an example of "send xxx in nn seconds" have a look at the Resource Center in the Help Menu of LiveCode.
Check -> Applications -> Displaying a count down (non-blocking). That can be used to make your timer, as has been suggested.
Also there are many scripts in the Resource Center you might be interested in.
Kind regards
Bernd
if you are looking for an example of "send xxx in nn seconds" have a look at the Resource Center in the Help Menu of LiveCode.
Check -> Applications -> Displaying a count down (non-blocking). That can be used to make your timer, as has been suggested.
Also there are many scripts in the Resource Center you might be interested in.
Kind regards
Bernd
Re: Sample Timer Scripts
I appreciate all of the responses and while I agree that there is great learning to be had in creating my own timer, I am not a programmer and loops,nested loops etc. boggle my mind.
However I know that my learning curve suits editing rather than creating.
All that said if someone does have a timer script that they can share or if a donation is required I am open to that also.
Don't want to appear to be lazy but my passion is the design and layout of the app not in the detail of creating a new timer from scratch.
I have created a stack that enables a user to input start and stop times and also input how often to have the timer run and have included it if anyone is interested in using it.
Any help or suggestions would be gratefully accepted.
However I know that my learning curve suits editing rather than creating.
All that said if someone does have a timer script that they can share or if a donation is required I am open to that also.
Don't want to appear to be lazy but my passion is the design and layout of the app not in the detail of creating a new timer from scratch.
I have created a stack that enables a user to input start and stop times and also input how often to have the timer run and have included it if anyone is interested in using it.
Any help or suggestions would be gratefully accepted.
- Attachments
-
- UserTimeInput.rev.zip
- (3.05 KiB) Downloaded 442 times
Re: Sample Timer Scripts
Well, you are on your way. You did make a stack, and with a group, no less.
OK. Fine. You still have to do this yourself, but here is a head start. Make a button. Make three fields. Name one field "startTime". Name another "testTime". Name the third "Output".
Put this in the button script:
After you get tired of watching it work, place a breakpoint right at the top, and step through line by line. The script is verbose, but that is so you can see better what is happening. Make this into a multi-level timer with several intervals.
Even if someone hands you a working gadget, it will lack what you need, and contain what you do not. The only way through this is to make it your way. This is a good thing.
You may find a new passion. Writing code is far richer than designing layouts. Write back. We all expect to hear from you often.
Craig Newman
OK. Fine. You still have to do this yourself, but here is a head start. Make a button. Make three fields. Name one field "startTime". Name another "testTime". Name the third "Output".
Put this in the button script:
Code: Select all
on mouseUp
put word 1 of the long time into currentTime
put word 1 of the long time into fld "startTime"
convert currentTime to dateItems
add 5 to item 6 of currentTime
convert currentTime to long time
put word 1 of currentTime into fld "testTime"
put "The end is near" into fld "output"
repeat until the mouseClick --just a safety
put word 1 of the long time into fld "startTime"
if fld "testTime" <= fld "startTime" then
put "The end has come" into fld "outPut"
exit to top
end if
end repeat
end mouseUp
Even if someone hands you a working gadget, it will lack what you need, and contain what you do not. The only way through this is to make it your way. This is a good thing.
You may find a new passion. Writing code is far richer than designing layouts. Write back. We all expect to hear from you often.
Craig Newman
Re: Sample Timer Scripts
Here's another Timer Sample. Drop this code into a button called start.
Make sure the label is also called "start" all in lower case.
The 10 second count is hard coded. Change it to whatever you want.
Make sure the label is also called "start" all in lower case.
The 10 second count is hard coded. Change it to whatever you want.
Code: Select all
local cntr, started
on mouseUp
if the label of me = "start" then
set the label of me to "stop"
call "countUp"
else
set the label of me to "start"
end if
end mouseUp
on countUp
if the label of me = "stop" then
put the long seconds into started
put (the long seconds - started) into cntr
set the label of me to cntr
else if cntr >10 then
set the label of me to "start"
beep
exit to top
else
put (the long seconds - started) into cntr
set the label of me to cntr
end if
-- breakpoint
send "countUp" to me in 0.20 seconds
end countUp
Re: Sample Timer Scripts
Hi guys,
no need to CALL this handler, since it is in the current message hierarchie
Best
Klaus
no need to CALL this handler, since it is in the current message hierarchie

Code: Select all
on mouseUp
if the label of me = "start" then
set the label of me to "stop"
##!!!
countUp
else
set the label of me to "start"
end if
end mouseUp
## Here it is :-)
on countup
...
Klaus