ASOC: Part of object specifier (?) is lost in debug mode?

The following sort of code fails to work in debug mode. Not sure whether anything can be done about this?

use framework "Foundation"
use scripting additions

local theResult
tell application "iTunes" to set theResult to its tracks
return 0

1 Like

Thank you for reporting this bug in the debugger. I have been able to resolve this problem in the upcoming Script Debugger 6.0.1 release.

That’s awesome! :smile:

Just to be completely on the safe side, although I’m assuming this is the case… the fix will also enable code such as the following to be debugged, correct? I.e. with the list of object specifiers returned by a run script command and used as the parameter in a handler call. Thanks! :slight_smile:

use framework "Foundation"
use scripting additions


tell application "iTunes" to my handle(run script "tell app \"iTunes\" to tracks")

on handle(tracks)
    return name of first item of tracks
end handle

This code works in as much as you can step through the statements in the debugger and see the value of the tracks variable. However, the use of the run script command prevents Script Debugger from exploring into the returned object specifiers. This is actually an AppleScript issue, but suffice to say that you will have a better debugging experience dealing with object references that do not originate from a run script command:

tell application "iTunes"
	my handle(tracks)
end tell

on handle(tracks)
	return name of first item of tracks
end handle

If you use this version, and step into the handle handler you’ll notice how the items of the tracks array can be expanded to view their properties.

I realize my version using ‘run script’ is a somewhat convoluted construct. But as long as it will be possible to execute and step through the code I posted in debug mode, then that’s perfectly fine (i.e., while that would be the icing on the cake, I don’t necessarily need to explore the contents of each object originating from the return value of the run script command in my case). I’m using run script so as to be able to build object specifiers with where clauses etc. at runtime, simplifying my code and giving me a tremendous speed advantage over other alternatives I’ve tried or managed to think of so far. :grimacing:

I was also somewhat irritated with AppleScript at first as to why the application specifier of the current application instead of iTunes was utilized for the returned object specifiers whenever I didn’t include the outer tell clause for iTunes. But it does work exactly as I expect it to now, outside of Script Debugger’s debug mode at this point.

Although I’m surprised the ‘live’ objects using the correct application specifier are shown in the result pane (for non-ASOC scripts) but not in the variables pane with the variable declared as local? But I suppose the results pane simply gets its content unchanged from AppleScript without whatever is messing up the debugger, resulting in the change of application specifiers, being involved in the process? Anyway, just a curiosity. I’m already happy as can be that the original issue that this thread is about will be fixed. :slight_smile:

Yes, the mechanisms used to extract global and local variables are very different, and use of the run script command denies Script Debugger access to some critical information within the AppleScript instance used by the run script command.

1 Like