Leopard treats "file" differently

Consider this code

set theFile to POSIX path of "OSX:Users:peter:Documents:Clip Manager Clips:CM2:AddNumbers.xml"
set thePosixFile to POSIX file theFile
tell application "Finder"
	displayed name of thePosixFile
end tell

In Tiger this works, in Leopard this fails.

the value of thePosixFile in both Tiger and Leopard is:
file “OSX:Users:peter:Documents:Clip Manager Clips:CM2:AddNumbers.xml”

But Leopard needs the following syntax (took me some time to find this one out ):

Luckily this syntax is compatible with Tiger, but it appears to me this is an AppleScript bug in Leopard.

Hi,

I don’t think so.

Unfortunately the keyword file has various meanings.

file can be a file reference like

set a to a reference to file ((path to startup disk as text) & "Library:Keychains:System.keychain")

or a file URL like

set a to POSIX file "/Library/Keychains/System.keychain"

or the class file of the dictionary of the Finder

tell application "Finder" to set a to file ((path to startup disk as text) & "Library:Keychains:System.keychain")

file reference and file URL have only one property which is POSIX path
only the Finder class file has a property displayed name.

Maybe in Tiger the Finder coerced politely the file URL to its own file class and Leopard refused to do this.

I would recommend to coerce a file URL always to an alias to avoid weird behavior

set theFile to POSIX path of "OSX:Users:peter:Documents:Clip Manager Clips:CM2:AddNumbers.xml"
set thePosixFile to POSIX file theFile as alias
tell application "Finder"
	displayed name of thePosixFile
end tell

Hi Stefan,
Thanks very much for the extensive explanation. Great stuff. – peter