make list of records (from a list of tracks) in one line

Hi everyone

I am new to this forum, and also kind of new to applescript. Hope somebody can help me.

I have this problem.

I want to make a list of records. I have some code to do it, but its not fast enough.

to itunes_data()
	tell application "iTunes"
		set tlist to tracks of library playlist 1
		set resultlist to {}
		set cnt to count tlist
		repeat with t from 1 to cnt
			copy {id1:persistent ID, moddate:modification date, pc:played count, sc:skipped count} of item t of tlist to end of resultlist
			tell me to log "" & t & " of " & cnt
		end repeat
	end tell
	
	return resultlist
end itunes_data

is there any way to make it a one liner?

like for instance:

set resultlist to {id1:persistent ID, moddate:modification date, pc:played count, sc:skipped count} of tracks in library playlist 1

I have tried this line, but it makes a record containing the four lists. What i am interestet in, is a list of length (count library playlist 1) containing records of length 4.

Wouldnt that make it a lot faster?

Model: MacBook
AppleScript: 1.10.7
Browser: Safari 522.12.1
Operating System: Mac OS X (10.4)

Hi and welcome,

unfortunately you can’t do this in one line.
This workaround is approx. twice as fast (on my machine)

to itunes_data()
	script o
		property _ID : {}
		property _modDate : {}
		property _pc : {}
		property _sc : {}
	end script
	tell application "iTunes" to tell tracks in library playlist 1 to set {{o's _ID, o's _modDate, o's _pc, o's _sc}, cnt} to {{persistent ID, modification date, played count, skipped count}, count it}
	set resultlist to {}
	repeat with t from 1 to cnt
		set end of resultlist to {id1:item t of o's _ID, moddate:item t of o's _modDate, pc:item t of o's _pc, sc:item t of o's _sc}
	end repeat
	return resultlist
end itunes_data