AppleScript:无法引用文件

时间:2019-03-29 11:39:02

标签: file integer applescript posix plist

当引用该文件时,我有一个脚本可以正常工作,但是当我尝试添加对话框来选择文件时,总是出现错误

  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

错误:

  

错误“系统事件出错:无法制作文件”,Macintosh   HD:Users:kevin:Desktop:Time \“转换为整数类型。”数   -1700从文件“ Macintosh HD:Users:kevin:Desktop:Time”转换为整数

我的原始脚本使用以下格式:

  

将plistfile_path设置为“〜/ Desktop / Time / myTime29_March.plist”

如何解决对话框问题?

1 个答案:

答案 0 :(得分:1)

property list file的参数不能是AppleScript alias的说明符。

将别名强制为文本

set p_list to property list file (config_file as text)