Applescript 1-2-3 tell block help

Just started reading Applescript 1-2-3 and need help with one of the examples. I can’t get it to work, I’ve tried on three computers (two snow leopard and one leopard).

tell application "Finder"
	tell the front Finder window
		set the target to home
		set the current view to home
		set the position to {0, 22}
	end tell
end tell

The problem is with the target to home line. Every time I run the script it throws an error: “Finder got an error: Can’t set Finder window 1 to home of Finder window 1.” I have been able to set finder windows to target home without using a tell block, but for some reason the tell block version isn’t working. What am I missing?

This example is from pg. 50 of AppleScript 1-2-3, in case anyone wants to look it up.

Model: MacBook
AppleScript: 2.1.1
Operating System: Mac OS X (10.6)

Hi,

home is a property of the application, not of a window
and current view expects a constant like list view.
Setting a variable to the home folder solves the problem


tell application "Finder"
	set myHome to home
	tell front Finder window
		set target to myHome
		set current view to list view
		set position to {0, 22}
	end tell
end tell

Thank you StefanK, just tested this out and it works. I’m glad it wasn’t just me being stupid. Although I did mess up the current view line when I typed the script into the forum, it says icon view not home. It seems funny to me that an “Apple Certified” book would have such an uncorrected error (I check the errata on the web before posting). I suppose I should send them a note.