Почему мой цикл Applescript терпит неудачу почти все время? Как ни странно, иногда это работает - PullRequest
0 голосов
/ 19 ноября 2018

Код ниже используется для запуска образца текста в 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 ""
...