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!
In my stack I have 2 options: to either trigger a handler in the Next button at defined intervals (currently in seconds for testing purposes) or at a specific time.
Setting the the time intervals was easy although there may be some simpler or more correct way. But setting the specific time is not working.
I'm using this code:
global gIncrement
on mouseUp
set the twelveHourTime to false
if the hilite of btn "Radio1" is "true" then
-- put (label of btn "everyhours" * 3600 + label of btn "everyminutes" * 60) into gIncrement
put (label of btn "everyhours" + label of btn "everyminutes") into gIncrement --used for development
if timerIncrement is not in the pendingMessages then -- don't pile up timerIncrement
send "timerIncrement" to me in gIncrement seconds
end if
else
doItAtTime
end if
end mouseUp
on timerIncrement
send "timerIncrement" to me in gIncrement seconds
send mouseUp to btn "next"
end timerIncrement
on doItAtTime
if the short time = (label of btn "onhour" &":"& label of btn "onminutes") then
send mouseUp to btn "next" in 62 seconds
end if
end doItAtTime
What do I have to correct to get the specific time setting working?
the stack is attached
Klaus wrote:what and where in the script is meant to "set the specific time"?
The script is in the "Save & Start"button and it is this:
....
else
doItAtTime
...
and
on doItAtTime
if the short time = (label of btn "onhour" &":"& label of btn "onminutes") then
send mouseUp to btn "next" in 62 seconds
end if
end doItAtTime
This is what I thought would work...
keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit
// theHandler: name of the command to be executed (no functions)
// theTime: the time when to execute the command
// assuming that useSystemDate is false
on sendCommandInTime theHandler,theTime
convert theTime from time to seconds
put theTime - the seconds into theSecondsToLapse
if theSecondsToLapse > 0 then
send theHandler to the target in theSecondsToLapse seconds
end if
end sendCommandInTime
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
global gIncrement
local theTime
on mouseUp
set the twelveHourTime to false
if the hilite of btn "Radio1" is "true" then
-- put (label of btn "everyhours" * 3600 + label of btn "everyminutes" * 60) into gIncrement
put (label of btn "everyhours" + label of btn "everyminutes") into gIncrement --used for development
if timerIncrement is not in the pendingMessages then -- don't pile up timerIncrement
send "timerIncrement" to me in gIncrement seconds
end if
else
put (label of btn "onhour" &":"& label of btn "onminutes") into theTime
sendCommandInTime "nextLine",theTime
end if
end mouseUp
on timerIncrement
send "timerIncrement" to me in gIncrement seconds
send mouseUp to btn "next"
end timerIncrement
// theHandler: name of the command to be executed (no functions)
// theTime: the time when to execute the command
// assuming that useSystemDate is false
on sendCommandInTime theHandler,theTime
convert theTime from time to seconds
put theTime - the seconds into theSecondsToLapse
if theSecondsToLapse > 0 then
send theHandler to the target in theSecondsToLapse seconds
end if
end sendCommandInTime
on nextLine
send mouseUp to btn "next"
end nextLine
I guess it's correct since it works
keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit
global gAllLines,gCurrentLine
on mouseUp
if gCurrentLine >= the num of lines of gAllLines then
exit mouseup
end if
add 1 to gCurrentLine
put line gCurrentLine of gAllLines into fld "oneline"
put gCurrentLine into fld "a"
put gCurrentLine into gCurrentLine
end mouseUp
Somehow, your posts come from a subdomain ftp.runrev.com instead of forums.runrev.com. It seems this mixes up things completely. I'll post the post that was supposed to be posted here first and will answer to your next post in another post
Mark
Hi,
You'll need another button AMPM and this line:
put (label of btn "onhour" &":"& label of btn "onminutes" && the label of btn "AMPM") into theTime
Before I post a new script, I think I should ask you what does button "Next" do and what does handler "nextLine" do exactly? If they're not too long, perhaps you should also post the handlers of the button and the nextLine handler.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
global gIncrement
on mouseUp
set the twelveHourTime to true
if the hilite of btn "Radio1" is "true" then
// assuming that labels of buttons contain integers 0-12 resp. 1-59.
put (label of btn "everyhours" * 3600 + label of btn "everyminutes" * 60) into gIncrement
if timerIncrement is not in the pendingMessages then -- don't pile up timerIncrement
send "timerIncrement" to me in gIncrement seconds
end if
else
// I assume the onhour and onminutes buttons to be the same as the every* buttons
// and you need a button "AMPM" unless you make a 24-hours version
put (the label of btn "onhour" &":"& the label of btn "onminutes" && the label of btn "AMPM") into theTime
sendCommandInTime "nextLine",theTime
end if
end mouseUp
on timerIncrement
send "timerIncrement" to me in gIncrement seconds
send mouseUp to btn "next"
end timerIncrement
on nextLine
send mouseUp to btn "next"
end nextLine
// theHandler: name of the command to be executed (no functions)
// theTime: the time when to execute the command
// assuming that useSystemDate is false
on sendCommandInTime theHandler,theTime
convert theTime from time to seconds
put theTime - the seconds into theSecondsToLapse
if theSecondsToLapse > 0 then
send theHandler to the target in theSecondsToLapse seconds
end if
end sendCommandInTime
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode