event handler failed WTF

when my Xcode project tries to execute a part of my script it gives this error:

a part of my script:

if name of theObject is "AOpen" then
		-- afspeellijst kiezen, en tracks naar list zetten
		tell application "iTunes" to set myOPlaylists to name of every playlist
		set myOCPlaylist to (choose from list myOPlaylists) as string
		tell application "iTunes"
			set myOTracks to {}
			set myCount to 1
			repeat count playlist myOCPlaylist times
				set myOTrack to name of track myCount of playlist myOCPlaylist
				set myOArtist to artist of track myCount of playlist myOCPlaylist
				set end of myOTracks to {myOTrack, myOArtist}
				set myCount to myCount + 1
			end repeat
		end tell
		
		-- alles naar tabel, list myPlaylist updaten
		set contents of table view "AGekozen" of scroll view "AGekozen" of window "add" to myOCPlaylist
		set myPlaylist to myOCPlaylist
	end if)

I’ve already gotten this error often, but mostly with the command

display dialog "A Text" buttons AList default button AButton

But I’ve never have gotten this error while trying to get information from an application.

Now what can I do to solve my problem?

Thanx,
ief2

Hi,

the problem is, a playlist has a few elements so count playlist returns always 0.

Again, the repeat x times and “manually” incrementing the index variable is bad programming habit.
This is more effective and faster code


.
tell application "iTunes" to set myOPlaylists to name of every playlist
set myOCPlaylist to (choose from list myOPlaylists) as text
if myOCPlaylist is "false" then return
tell application "iTunes"
	set myOTracks to {}
	repeat with myCount from 1 to (count tracks of playlist myOCPlaylist)
		tell track myCount of playlist myOCPlaylist
			set end of myOTracks to {its name, artist}
		end tell
	end repeat
end tell
.

well I have lots of bad scripting habits, but I just can’t remember your (and probably anyone else’s) method for looping thru files.

But the problem was not the iTunes tell block it was a bet reference to a list in a

set contents of table view "AName" of scroll view "AName" of window "AWindow" to AList

=> AList was a wrong list in my script

thanx anyway,
ief2

(Wauw, I have a lot of questions don’t I??? Sorry!)