CalendarLib EC is a script library for manipulating calendar events without using the Calendar application. Why? Its faster and probably more flexible.
This code snip shows a typical call to the library, note that the cal type is required and in this case is : cal cloud
set theStore to fetch store
set theCal to fetch calendar "Work" cal type cal cloud event store theStore
I have been attempting to pass the cal type in the form of a variable but the library throws an error “invalid cal type” and suggests that the type required is an item
set tCalType to CalendarType(pCalendarName, pCalTypesLst) -->
-->tCalType is a string "cal type"
set tSourceCal to fetch calendar pCalendarName cal type tCalType event store pTheStore
While I can hard code my call as per the first code snip I wonder if there is a way of coercing my variable into a form that is accepted by the fetch calendar handler. This handler is listed below and I have to admit that I do not understand the first code line → cal type calType, looking at the code here suggests that calType is a string but it is not as it gets displayed in blue in editor and a string throws an error.
-- You often need a reference to the relevant calendar; get it here.
on fetch calendar calName cal type calType event store theStore
if calType = cal local then
set calType to 0
else if calType = cal cloud then
set calType to 1
else if calType = cal exchange then
set calType to 2
else if calType = cal subscription then
set calType to 3
else if calType = cal birthday then
set calType to 4
else
error "Invalid cal type"
end if
....
thanks in advance,
Simon