AppleScript:无法引用文件

问题描述 投票:0回答:1

当文件被引用时,我有一个工作正常的脚本,但是当我尝试添加一个对话框来选择文件时,我总是会收到错误

  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:用户:kevin:桌面:时间\“进入类型整数。”编号-1700从文件“Macintosh HD:用户:凯文:桌面:时间”到整数

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

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

如何修复对话框问题?

file integer applescript posix plist
1个回答
1
投票

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

将别名强制转换为文本

set p_list to property list file (config_file as text)
© www.soinside.com 2019 - 2024. All rights reserved.