为什么我的Applescript循环几乎总是失败?奇怪的是,有时它可以工作

时间:2018-11-18 22:22:49

标签: loops applescript reminders

下面的代码用于在TextEdit中运行示例文本。大约有14次迭代,循环可能会失败。下面是脚本的更新的简化版本。仍然给我同样的问题

Compare the code in the new image with the dialog result

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 ""

0 个答案:

没有答案