list of records

I want to backup my photos and comments from iPhoto. Therefore I created a record


set pic to {album_name:"none", filename:"none", filepath:"none", my_comment:"none"}

Now I want to store this record in a list.


set pics to pic as list

I fill this list in a repeat loop:


repeat with photo_index from 1 to (count of my_photos)
	copy pic to new_pic
	set my_comment of new_pic to comment of item photo_index of my_photos
	set filename of new_pic to image filename of item photo_index of my_photos
	set filepath of new_pic to image path of item photo_index of my_photos
	set album_name of new_pic to name of item album_index of albums
	set pics to pics & new_pic
end repeat

But the problem is that the result is a list. So I can’t access the items this way:


repeat with i from 1 to (count of pics)
	set myvar to album_name of item i of pics
end repeat

Is this somehow possible a list of records ?

you need only a few additional curly brackets

set pic to {album_name:"none", filename:"none", filepath:"none", my_comment:"none"}
set pics to {}
repeat with photo_index from 1 to (count of my_photos)
	copy pic to new_pic
	set my_comment of new_pic to comment of item photo_index of my_photos
	set filename of new_pic to image filename of item photo_index of my_photos
	set filepath of new_pic to image path of item photo_index of my_photos
	set album_name of new_pic to name of item album_index of albums
	set pics to pics & {new_pic}
end repeat

you can also try this shorter version:

set pic to {album_name:"none", filename:"none", filepath:"none", my_comment:"none"}
set pics to {}
repeat with photo_index from 1 to (count of my_photos)
	copy pic to new_pic
	tell new_pic
		set {my_comment, filename, filepath} to {comment, image filname, image path} of item photo_index of my_photos
		set album_name to name of item album_index of albums
	end tell
	set pics to pics & {new_pic}
end repeat

thanks great

Better to use:

set end of pics to {new_pic}

Indeed “ though without the braces. :slight_smile:

Right!

Good eyes.

Thanks Nigel,