Re: Creating a Record
Re: Creating a Record
- Subject: Re: Creating a Record
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 26 Nov 2003 11:28:10 -0800
On 11/24/03 9:49 PM, "Darwin Zins" <email@hidden> wrote:
>
Sorry if this is an RTFM, but I have the following code:
>
>
tell application "iCal"
>
activate
>
>
set the_calendars to every calendar
>
set the_todos to {}
>
>
repeat with this_cal in the_calendars
>
set the_todos to every todo in this_cal
>
repeat with this_todo in the_todos
>
>
set this_todo to {uid:uid of this_todo as string, summary:summary of
>
this_todo as string, priority:priority of this_todo as string, due
>
date:due date of this_todo as string, completion date:completion date
>
of this_todo as string}
>
>
end repeat
>
>
end repeat
>
>
return this_todo
>
end tell
There's nothing wrong with that, but you're not _doing anything_ with each
iteration, so they all disappear except the last iteration. You're also not
setting up a special record as you describe below.
>
>
I need to make a record with the label being the uid and the value
>
being the contents of this_todo. I should concatenate the value of
>
this_todo to the end of this record with the label of the uid right
>
after I set this_todo so I end up with a record with the label equal to
>
the uid and the value equal to a record containing this_todo for every
>
todo item in my todo list. Is this possible and if so, how do I go
>
about it?
>
>
Thanks in advance for any help,
set recordsList to {}
tell application "iCal"
activate
set the_calendars to every calendar
set the_todos to {}
repeat with this_cal in the_calendars
set the_todos to every todo in this_cal
repeat with this_todo in the_todos
set this_UID to uid of this_todo as string
set this_record to {uid:this_UID, summary:summary of this_todo
as string, priority:priority of this_todo as string, due date:due date of
this_todo as string, completion date:completion date of this_todo as string}
set end of recordsList to {uid:this_UID,
full_record:this_record}
end repeat
end repeat
return recordsList
end tell
But if you plan to export this outside an iCal tell block, you'll probably
need to change the record labels to words that aren't iCal keywords, or you
may get raw code such as <<property wr11>> instead of 'summary'. You can do
this:
set recordsList to {}
tell application "iCal"
activate
set the_calendars to every calendar
set the_todos to {}
repeat with this_cal in the_calendars
set the_todos to every todo in this_cal
repeat with this_todo in the_todos
set this_UID to uid of this_todo as string
set this_record to {|uid|:this_UID, |summary|:summary of
this_todo as string, |priority|:priority of this_todo as string, |due
date|:due date of this_todo as string, |completion date|:completion date of
this_todo as string}
set end of recordsList to {|uid|:this_UID,
full_record:this_record}
end repeat
end repeat
end tell
return recordsList
That will work. And of course you may not need |uid| inside the internal
full_record as well as in its own label-space, but that's up to you.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.