Applescript refer a link to a file in current finder window

applescriptdialogfinder

Edited.

Where is my current script :

set plistfile_path to POSIX file "/users/moi/Desktop/Time/"

choose file with prompt "Please choose a file:" of type {"plist"} ¬
    default location plistfile_path


##set the plistfile_path to "~/Desktop/myTime.plist"
tell application "System Events"
    set p_list to property list file (plistfile_path)
    -- read the plist data
    set startTimeValue to value of property list item "startTime" of p_list
end tell

I don't manage to get it work using the choose file dialog.

I'm having this error :

"error "System Events got an error: Can’t make file \"Macintosh HD:Users:nadjarian:Desktop:Time:\" into type integer." number -1700 from file "Macintosh HD:Users:moi:Desktop:Time:" to integer
"

if I get script of the dialog, it's work fine with this list instead :

set the plistfile_path to "~/Desktop/myTime.plist"

any idea how to fix the error?

Best Answer

This seems to work for me,

I'm setting the patch with the variable P and set a to POSIX file p

Then I create a dialog with the default location of the variable A

set p to "/Users/usernmaHere/Desktop/Time"
set a to POSIX file p


set config_file to choose file with prompt "Locate your .plist config file and click OK" of type "plist" default location a

I added file limitation with " type "plist"