AppleScript:无法引用文件
AppleScript : unable to refer to a file
我有一个脚本,在引用文件时可以正常工作,但是当我尝试向 select 文件添加对话框时,我总是收到错误消息
set p to "/Users/kevin/Desktop/Time"
set plistfile_path 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 plistfile_path
tell application "System Events"
set p_list to property list file (config_file)
set startTimeValue to value of property list item "startTime" of p_list
end tell
错误:
error "System Events got an error: Can’t make file \"Macintosh
HD:Users:kevin:Desktop:Time\" into type integer." number
-1700 from file "Macintosh HD:Users:kevin:Desktop:Time" to integer
我的原始脚本使用这种格式:
set the plistfile_path to "~/Desktop/Time/myTime29_March.plist"
如何解决对话框问题?
property list file
的参数不能是 AppleScript alias
说明符。
将别名强制为文本
set p_list to property list file (config_file as text)
我有一个脚本,在引用文件时可以正常工作,但是当我尝试向 select 文件添加对话框时,我总是收到错误消息
set p to "/Users/kevin/Desktop/Time"
set plistfile_path 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 plistfile_path
tell application "System Events"
set p_list to property list file (config_file)
set startTimeValue to value of property list item "startTime" of p_list
end tell
错误:
error "System Events got an error: Can’t make file \"Macintosh HD:Users:kevin:Desktop:Time\" into type integer." number -1700 from file "Macintosh HD:Users:kevin:Desktop:Time" to integer
我的原始脚本使用这种格式:
set the plistfile_path to "~/Desktop/Time/myTime29_March.plist"
如何解决对话框问题?
property list file
的参数不能是 AppleScript alias
说明符。
将别名强制为文本
set p_list to property list file (config_file as text)