Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Calendar Script Additions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Calendar Script Additions
Authored by: dashard on Apr 07, '02 04:23:36PM
Building on the work of those who have gone before ;-) I added a feature to the cal script which will choose one of the 8 installed calendars to display facts from. It will also check to make sure that the random calendar selected isn't empty for that day and choose anouher if it is. It doesn't trap fpr the possibility of ALL of the calendars being empty, but I'm just being lazy right now. Contact me if that's something you're interested in.
set myCalendarArray to {"birthday", "computer", "holiday", "music", "christian", "history", "judaic", "usholiday"} 
set randNum to (random number from 1 to count of myCalendarArray)
set randomChoice to item randNum of myCalendarArray
set myShellScript to " /usr/share/calendar/calendar." & randomChoice
set n to do shell script "calendar -f" & myShellScript
tell application "Finder"
activate
repeat while n = ""
set randNum to (random number from 1 to count of myCalendarArray)
set myChoice to item randNum of myCalendarArray
set myShellScript to " /usr/share/calendar/calendar." & myChoice
set n to do shell script "calendar -f" & myShellScript
end repeat
display dialog "Calendar:
" & n buttons {"Clipboard", "OK"} giving up after 10 default button 2
-- feel free to comment this next line out. I chose to let the dialog
-- auto-dismiss after 10 in the same way that the "Cool" dialog
-- in the steps below does.

if the button returned of the result is "Clipboard" then
set the clipboard to n display dialog "The calendar is on the clipboard." buttons
{"Cool"} giving up after 5 default button 1
-- the "giving up after 10 " part basically assumes it's cool
-- after 10 seconds of inactivity and removes the dialog
end if
end tell


[ Reply to This | # ]
Calendar Script Additions
Authored by: dashard on Apr 07, '02 04:36:43PM
You can also comment out the Finder "Tell" block, since it's not *really* necessary. This will just direct the output to the front application (which may be preferable if you're running this from ScriptMenu.) Commented-out version follows:
set myCalendarArray to {"birthday", "computer", "holiday", "music", "christian", "history", "judaic", "usholiday"}
set randNum to (random number from 1 to count of myCalendarArray)
set randomChoice to item randNum of myCalendarArray
set myShellScript to " /usr/share/calendar/calendar." & randomChoice
set n to do shell script "calendar -f" & myShellScript
--tell application "Finder"
-- activate
repeat while n = ""
set randNum to (random number from 1 to count of myCalendarArray)
set myChoice to item randNum of myCalendarArray
set myShellScript to " /usr/share/calendar/calendar." & myChoice
set n to do shell script "calendar -f" & myShellScript
end repeat
display dialog "Calendar:
" & n buttons {"Clipboard", "OK"} giving up after 10 default button 2
-- feel free to comment this next line out. I chose to let the dialog
-- auto-dismiss after 10 in the same way that the "Cool" dialog
-- in the steps below does.

if the button returned of the result is "Clipboard" then
set the clipboard to n display dialog "The calendar is on the clipboard." buttons
{"Cool"} giving up after 5 default button 1
-- the "giving up after 10 " part basically assumes it's cool
-- after 10 seconds of inactivity and removes the dialog
end if
--end tell


[ Reply to This | # ]