home *** CD-ROM | disk | FTP | other *** search
- /* Event!-Example-Script */
- /* (c) 1992-4 by Stefan Hochmuth */
-
- /* ARexx-Initialisations */
- address "EVENT!"
- options results
-
- /* Display Header */
- say "===== EVENT! Status ====="
- say ""
-
- /* Ask for current config name */
- 'STATUS 0'
- filename=result
-
- /* Get number of events */
- 'STATUS 1'
- eventcount=result
-
- /* Display them */
- say "Config : "||filename
- say "Entries: "||eventcount
-
- /* Display Status message in the clock's window */
- /* 'DISPLAY "2,0,Searching next event occurrence"' */
-
-
- /* Get next occuring event without the ones containing the string 'clock'
- 'cause I've got an event called "ClockWindow to Front" which
- occurs every minute */
- 'WHENWILL "~(**clock**)"'
- OCString=result
-
- /* Parse result from Event! */
- CALL ExtractFromOccurString
-
- say ""
- /* If an event occurs within 366 days then display it */
- If OccurMins~==0 then do
- say "The next event occuring within 366 days is: "||eventname
- say "It occurs in approx. "||days||" days and "||hours||":"||mins||" h"
- end
- /* Otherwise inform the user */
- else say "No event occuring within the next 366 days"
- say ""
-
- say "Time Based events in the near future:"
- say ""
-
- /* Another message in the clock's window */
- /* 'DISPLAY "Showing future occurrences"' */
-
-
- /* Display Header */
- say "Event Name Days to go Hours To go"
- say "--------------------------------------------------------------"
-
- /* Get Occurance Time for all events */
- do i=1 to eventcount
- WHENWILLNR i
- OCString=result
- /* Convert the result */
- CALL ExtractFromOccurString
- /* If the result is -1 then the event will occur in more than 366 days
- if ever */
- If OccurMins==-1 then do
- say Substr(EventName,1,44) "*** > 366 days ***"
- end
- else do
- /* Otherwise, if not zero (the event exists and is timebased) */
- If OccurMins~==0 then do
- say Substr(EventName,1,44) days " " hours||":"||mins||" h"
- end
- end
- end
-
- /* Now we will optionally add an event */
-
- say ""
- say ""
- say "Do you want to add a new event? (y/N)"
- pull answer
- if upper(answer)="Y" then do
- /* Check out if the event is already there */
- 'EXISTS "ARexx-Add"'
- if result~==0 then do
- if result==1 then say "There already exists an event"
- else say "There already exist "||result" events"
- say "called 'ARexx-Add' added by ARexx."
- say "Do you want to add another one? (Y/n)"
- pull answer
- end
- else do
- answer="y"
- end
-
- if upper(answer)="Y" then do
- /* Add the event */
- 'EVENT "ARexx-Add"
- ONTIME
- ONCE BEEP BLINK WINFRONT SCREENFRONT KILLDONE
- WHEN "#3 #26 #6 #92 #12 #18 0"
- DISPLAY "5,0,This event was added by ARexx and removes itself right now!"
- '
- /* Display Footer */
- if rc==0 then do
- say ""
- say "I added an event called 'ARexx-Add'"
- say "It will occur at the next full minute!"
- end
- else do
- say ""
- say "There was an error adding 'ARexx-Add'"
- end
- end
- end
-
- /* Display Requester */
-
- 'REQUEST "End of;EVENT!''s;Demonstration"'
-
-
- exit 0
-
-
-
- /****** Subroutines ******/
-
-
- /********************* ExtractFromOccurString ***************************/
- /* In: OCString as received from Event!'s command WHENWILL(NR) */
- /* Out: OccurMins=-1 if the event won't occur within the next 366 days */
- /* OccurMins=0 if the event doesn't exist or isn't "On Time" */
- /* Otherwise: hours=hours to go (formatted) */
- /* mins=additional minutes to go (formatted) */
- /* days=days to go (formatted) */
-
- ExtractFromOccurString:
- parse var OCString OccurMins EventName
- if OccurMins~==-1 then do
- hours=occurmins%60
- mins=RIGHT(occurmins//60,2,"0")
- days=RIGHT(hours%24,3," ")
- hours=RIGHT(hours//24,2," ")
- end
- return
-