Get path of current document in pages

I want to write a script that gets the path of the frontmost document in the app “pages”. Then display the path in a dialog and ask me what a want to do with the path. Or it has to open the parent directory or just nothing.
It all goes well until the opening of the folder in a new finder window. Pages returns a POSIX path and I don’t know how to change a POSIX path into an alias. When I try to set the target of the frontmost finder window to the container of the POSIX Path of the path to the document, it says that the folder does not exists.

My script:

tell application "Pages"
	set myPath to path of document 1
	set myString to myPath & return & return & "What do you wanna do?"
	
	display dialog myString buttons {"Nothing", "Open Container"} default button 2
	
	if button returned of result is "Open Container" then
		tell application "Finder"
			make new Finder window
			set target of Finder window 1 to container of (POSIX path of myPath)
			tell result to activate
		end tell
	end if
end tell

Thanks in advance,
ief2

PS.: I’m sorry for my English. I know I sometimes make some rubbish sentences, but I ask you to forgive me. I’m only 14 years old and I come from Belgium, so I speak dutch. If you don’t understand me, don’t hesitate to give a reply on that.

Model: iMac G5
Browser: Safari 531.9
Operating System: Mac OS X (10.5)

Hi,

your english is at least good enough to describe your problem precisely :wink:

unlike the shell AppleScript works with HFS paths (colon separated).
You can coerce a POSIX path to an alias with (POSIX file . as alias)

The Finder command reveal shows the file in a new Finder window.
Note: try always to avoid nested application tell blocks.


tell application "Pages" to set myPath to path of document 1

set myString to myPath & return & return & "What do you wanna do?"

display dialog myString buttons {"Nothing", "Open Container"} default button 2

if button returned of result is "Open Container" then
	tell application "Finder" to reveal (POSIX file myPath as alias)
end if

Thanks StefanK for helping me again.