time, timing, routine events, etc...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
time, timing, routine events, etc...
So here I am with this cool script that I've written and everything is happy - I've tested and satisfied with the outcome (Thanks to everyone for their help!) but I've encountered a small snag and could use some guidance...
My script is intended to go grab information at regular intervals (preferable every 10 minutes before the hour), parse that information, and put it into a pre-defined location -- other than the recurring timing issue, things are happy.
As I went over the documentation for an extensive period of time, I couldn't sort out a decent way to let my script monitor the time and execute the sub-routines when the parameters were met... Has anybody worked through this situation and come up with a workable solution, short of a bunch of if-then statements?
Thanks in advance!
Bob
My script is intended to go grab information at regular intervals (preferable every 10 minutes before the hour), parse that information, and put it into a pre-defined location -- other than the recurring timing issue, things are happy.
As I went over the documentation for an extensive period of time, I couldn't sort out a decent way to let my script monitor the time and execute the sub-routines when the parameters were met... Has anybody worked through this situation and come up with a workable solution, short of a bunch of if-then statements?
Thanks in advance!
Bob
Hi Bob,
This should do what you want:
Best,
Mark
This should do what you want:
Code: Select all
constant cTimeMinutes = 50
on foo
-- kill any existing messages
put item -2 of the last line of the executionContexts into myHandler
put the pendingMessages into myMsgList
filter myMsgList with ("*" & comma & myHandler & comma & "*")
repeat for each line myMsg in myMsgList
cancel item 1 of myMsg
end repeat
-- Now do whatever you want here and then
-- continue script.
beep
-- Calculate the seconds
set the itemdel to colon
put the short time into myOldTime
put item 1 of (word 1 of myOldTime) into myOldHour
if item 2 of (word 1 of myOldTime) >= cTimeMinutes then add 1 to myOldHour
if myOldHour > 24 then
put "0" into myOldHour
put "AM" into mySuffix
else
put the last word of myOldTime into mySuffix
end if
put myOldHour & colon & cTimeMinutes && mySuffix into myNewTime
convert myOldTime to seconds
convert myNewTime to seconds
put myNewTime - myOldTime into myNewTime
-- Do again in myNewTime secs
send "foo" to me in myNewTime secs
end foo
Mark
Last edited by Mark on Sat Apr 26, 2008 1:57 am, edited 1 time in total.
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Excellent!
I'll drop your code into my script and play with it, but the logic looks like what I was shooting for. Thanks much for the contribution - I'll let you know how it turns out.
Works great, one updated item to note...
The script works great, however, if you're planning on using this script, please note that you need to initialize cTimeMinutes by putting the minute marker you want to count toward. In other words, if you're looking to trigger the event every 50 minutes after the hour, you need to insert:
put 50 into cTimeMinutes
in the area of your main script (right where it says, " -- Now do whatever you want here and then continue script.)
bingo, you're in business!
My special thanks to Mark for his contribution to making my project a success.
put 50 into cTimeMinutes
in the area of your main script (right where it says, " -- Now do whatever you want here and then continue script.)
bingo, you're in business!
My special thanks to Mark for his contribution to making my project a success.
Hi Bob,
You got it right, although I defined cTimeMinutes as a constant;
I'll update the script above to take this into account.
Best,
Mark
You got it right, although I defined cTimeMinutes as a constant;
Code: Select all
constant cTimeMinutes = 50
Best,
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
A point of frustration (or two)...
Well, the build runs fine on my Mac, before I build it as a stand alone app and move it to the PC... However, when I move it to the PC, it will run for some time (an hour or more, but not significantly longer). Then the build crashes and needs to be restarted. Such is life under Windows, eh?!
So, I figured I'd take a different approach and drop the entire script into the Stack Script, with an "on openStack" - seemed like a good idea at the time! Once I had it running under a Windows build I'd set a Windows script to re-run the app every hour to gather my info.
Hmmm... I run into a problem, however - I can't get the script to run on openStack. No errors reported in the compile, nor when I open the stack.
The script, however, attached to a button on the card, works just fine...
Any suggestions where I'm going wrong, or what I'm missing in the big picture?
Thanks for your time,
Bob
So, I figured I'd take a different approach and drop the entire script into the Stack Script, with an "on openStack" - seemed like a good idea at the time! Once I had it running under a Windows build I'd set a Windows script to re-run the app every hour to gather my info.
Hmmm... I run into a problem, however - I can't get the script to run on openStack. No errors reported in the compile, nor when I open the stack.
The script, however, attached to a button on the card, works just fine...
Any suggestions where I'm going wrong, or what I'm missing in the big picture?
Thanks for your time,
Bob
Don't know why...
Well, it turns out that if you're working in the IDE, when you open the stack it doesn't appear to run the openStack command. However, I still found the same problem after a build.
I did, however, find a solution: If I issued an on openStack command that clicked my working button, the system did exactly what it was supposed to.
Then, I had the pleasure of working out the Scheduled Task option in Win XP. In the end, I set Scheduled Task to run every 10 minutes (forever) and build a quit command into my Revolution script.
Not quite the way I'd like everything to work, but in the end we're all about making it work, eh?
I did, however, find a solution: If I issued an on openStack command that clicked my working button, the system did exactly what it was supposed to.
Then, I had the pleasure of working out the Scheduled Task option in Win XP. In the end, I set Scheduled Task to run every 10 minutes (forever) and build a quit command into my Revolution script.
Not quite the way I'd like everything to work, but in the end we're all about making it work, eh?