Task: Get Events
1. Array Clear %CalEvents // Clear existing array
2. Variable Convert %DATE to Date Time To Seconds // Get the current time, convert it into seconds since epoch
3. Variable Set %intervalorday to 0 // Choose whether to check forward from the beginning of the current day, or from the present moment
4. Variable Set %interval to 24 // How many hours to look forward
5. Variable Set %testinterval to 60*15 DO MATHS // How granular the search through the calendar is (60 seconds times 15 minutes)
6. Variable Set %schedstart to %TIMES // We start now. There's no point looking back in time.
7. Variable Set %schedend to %date + (60*60*%interval) IF %intervalorday eq 0 // If we want to check from the beginning of the day, set the end time for (beginning of day + chosen interval)
8. Variable Set %schedend to %TIMES + (60*60*%interval) IF %intervalorday eq 1 // If we want to check from now, set the end time for (now + chosen interval)
9. Test App Calendar Title data %schedstart store as %event LABEL TEST NEXT EVENT // Get title, calendar, start time, end time, and location from the current position of the counter in the calendar
10. Test App Calendar Calendar data %schedstart store as %calendar //
11. Test App Calendar Start (Seconds) data %schedstart store as %eventstart //
12. Test App Calendar End (Seconds) data %schedstart store as %eventend //
13. Test App Calendar Location data %schedstart store as %eventlocation //
14. If %event(#) neq 0 & %eventstart1%eventend1%eventlocation1%event1 !~ %doubleevent // If we find something at the current position in the calendar, and it's not the fingerprint of something else we've seen
15. Variable Set %eventdurations to %eventend1-%eventstart1 // Find the duration of the event (in seconds)
16. Perform Task SecondsToDHMS %par1 %eventdurations return %evenduration // Get a human legible format of the duration
17. Array Push %CalEvents position 9999 value %eventstart1::%event1::%eventlocation1::%eventduration // Add the information to the global list of upcoming events
18. Variable Set %doubleevent to %eventstart1%eventend1%eventlocation1%event1 // Set the signature for the current entry
19. End If //
20. Variable Add %schedstart value %testinterval // Increment the counter
21. Goto Action Label TEST NEXT EVENT // Check the next position
Task: SecondsToDHMS
1. Variable Set %days to floor(%par1 / 86400) DO MATHS
2. Variable Set %hours to floor((%par1 % 86400) / 3600) DO MATHS
3. Variable Set %minutes to floor((%par1 % 3600) / 60) DO MATHS
4. Variable Set %seconds to %par1 % 60
5. Variable Set %return to %days day APPEND, IF %days eq 1
6. Variable Set %return to %hours hour APPEND, IF %hours eq 1
7. Variable Set %return to %minutes minute APPEND, IF %hours eq 1
8. Variable Set %return to %seconds second APPEND, IF %seconds eq 1
9. Variable Set %return to %days days APPEND, IF %days > 1
10. Variable Set %return to %hours hours APPEND, IF %hours > 1
11. Variable Set %return to %minutes minutes APPEND, IF %minutes > 1
12. Variable Set %return to %seconds seconds APPEND, IF %seconds > 1
13. Return %return
Task: ReadEvents
1. IF %CalEvents(#) > 0 // If there any events in the global list
2. For %event in %CalEvents() // Iterate through them
3. Variable Split %event splitter :: // Split the entry up
4. Array Push %calevents position 9999 value %event IF %event1 > %TIMES // If the event hasn't passed yet, add it to the local list
5. End For //
6. Say You have no events today. IF %calevents(#) eq 0 // If all the events have passed, say there aren't any upcoming
7. IF %calevents(#) > 0 // If there are events still to come
8. Say You have one upcoming event IF %calevents(#) eq 1 // Say if there's one
9. Say You have %calevents(#) upcoming events IF %calevents(#) > 1 // Say if there's more
10. For %event in %calevents() // Iterate through the local list
11. Variable Split %event splitter :: // Split the entry
12. Variable Convert %event1 Seconds to Medium Date Time store in %time // Convert the time from seconds to something humans can understand
13. Say %time: %event2: at %event3: for %event4 // Say the event
14. End For //
15. End If //
16. Else //
17. Say You have no upcoming events // If there's nothing in the global list, then there can't be any upcoming, so tell the user.