loops - 为什么我的 Applescript 循环几乎总是失败?奇怪的是,它有时有效
问题描述
下面的代码用于在 TextEdit 中运行示例文本。大约有 14 次迭代,循环可能在其中任何一次中失败。以下是脚本的更新简化版本。它仍然给我同样的问题
set AppleScript's text item delimiters to ":"
tell application "TextEdit"
activate
tell the front document
set nameList to the first paragraph
set remindersList to {}
set lineCount to count the paragraphs
repeat with i from 2 to lineCount
set reminderName to paragraph i
set end of remindersList to reminderName
end repeat
end tell
end tell
tell application "Reminders"
set newList to make new list
set name of newList to nameList
set reminderDate to date
set listAccount to account
lineCount = lineCount - 2
repeat with i from 1 to lineCount
tell list nameList
set newremin to make new reminder
set reminderName to item i of remindersList
set {remName, remBody1, remBody2} to {text item 1, text item 2, text item 3} of reminderName
set name of newremin to remName
set body of newremin to remBody1 & return & remBody2
set due date of newremin to (current date) + (1 * days)
end tell
end repeat
end tell
set AppleScript's text item delimiters to ""
解决方案
推荐阅读
- reactjs - 是否会出现此错误“findDOMNode 在 StrictMode 中已弃用”。部署我的反应项目时失败?
- android - 如何在不登录的情况下验证另一个电话号码的firebase otp?
- python - 终端中的 Python 路径到 Anaconda
- c# - 在列表和函数中传递动态类型
- shell - 是否可以使用pycharm执行一段用文本文件编写的命令?
- python - PyGame将屏幕移动到另一个文件?
- javascript - 将选定的过滤器与 URL 参数同步
- sql - 当我希望员工不低于 18 岁且不高于 60 岁时,为什么会出现此错误?
- python - django logging - 无法将日志打印到文件
- javascript - 在 JavaScript 中的 For 循环中计算对象的属性数