I have this calendar code pulling event info from a specific calendar. I would like to change the output to 2 lines (Currently this will output all event info on a single line). Ive tried a few ways of doing this, they have all failed. Would like the last part of this code "︎" substr($4,19)}'"" displayed on the second line.
I do this to, I ended up running two commands. One for the info in the first line, one to the info for the second line.
-- start time here
set upcomingEventsTime to do shell script "/usr/local/bin/icalBuddy -n -nc -ic D67AE76B-5C14-4966-8F2A-716825956339 -ec -ps \"|• |\" -iep \"datetime\" -po \"datetime\" -tf \"%1Hh%M\" -df \"%a\" -eed eventsToday+7 | awk -F \"• \" '{print toupper(substr($2,1,1)) tolower(substr($2,2))\"\"$3}'"
set eventsListTime to theSplit(upcomingEventsTime, "
")
set findReplaceTime to the first item of eventsListTime
--Delete 'Today at'
set outputTime to replaceText("Today at ", "", findReplaceTime)
-- start title here
set upcomingEventsTitle to do shell script "/usr/local/bin/icalBuddy -n -nc -ic D67AE76B-5C14-4966-8F2A-716825956339 -ec -ps \"|• |\" -iep \"title\" -po \"title\" -tf \"%1Hh%M\" -df \"%a\" -eed eventsToday+7 | awk -F \"• \" '{print toupper(substr($2,1,1)) tolower(substr($2,2))\"\"$3}'"
set eventsListTitle to theSplit(upcomingEventsTitle, "
")
set findReplaceTitle to the first item of eventsListTitle
--Delete 'Today at'
set outputTitle to replaceText("Today at ", "", findReplaceTitle)
--return bith here
return outputTime & "
" & outputTitle
on theSplit(theString, theDelimiter)
-- save delimiters to restore old settings
set oldDelimiters to AppleScript's text item delimiters
-- set delimiters to delimiter to be used
set AppleScript's text item delimiters to theDelimiter
-- create the array
set theArray to every text item of theString
-- restore the old setting
set AppleScript's text item delimiters to oldDelimiters
-- return the result
return theArray
end theSplit
--@yyuuiko: Find Replace function
on replaceText(find, replace, subject)
--set subject to "a"
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to subject as text
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText
--thanks @yyuuiko for the base of the code
mh that should work with "\n" in the returned string. But escaping this stuff im shell scripts run from apple scripts can be nasty. I'll look into it tomorrow.
Thats what I thought too. Tried and failed \r \n, no good... Would be much cleaner code then calling icalbuddy twice. Quickly edited my code and have the output working calling it twice (wasn't difficult), but its just ugly IMO. Actually all of icalbuddy is pretty ugly code. LOL
I did a little work with two calls to icalbuddy. As much as I dont like that, I do have some output I can work with. Still needs some work and I'm going to clean up some of this code for my use. Using this to re-format my sports schedules.
This would be pure gold, worth for speed and energy!
Unfortunately I didn't manage getting two lines, and more important how to select one item from the string