“Applescript打印”;“缺少值”;而不是空字符串

“Applescript打印”;“缺少值”;而不是空字符串,applescript,Applescript,我用这个Applescript在我的桌面上用GeekTool显示一个名为“Cities”的列表中的提醒,但由于某些原因,该列表中的每个提醒都在正文中没有任何内容,因此它会打印出“缺少的值”。我怎样才能让它不那么坏呢 set theList to {} set theOutput to "" tell application "Reminders" repeat with i from 1 to (count of every reminder of list "Cities")

我用这个Applescript在我的桌面上用GeekTool显示一个名为“Cities”的列表中的提醒,但由于某些原因,该列表中的每个提醒都在正文中没有任何内容,因此它会打印出“缺少的值”。我怎样才能让它不那么坏呢

set theList to {}
set theOutput to ""

tell application "Reminders"
    repeat with i from 1 to (count of every reminder of list "Cities")
        if reminder i of list "Cities" is not completed then
            set theList to theList & {name, body} of reminder i of list "Cities"
        end if
    end repeat
    repeat with i from 1 to (count of every item of theList)
        set theOutput to (theOutput & item i of theList as string) & return
    end repeat
    return theOutput
end tell
我想要的输出是:

伊斯坦布尔-2008年3月访问 拉斯维加斯 京都-2012年2月访问

目前:

伊斯坦布尔 2008年3月访问 拉斯维加斯 京都
2012年12月访问

之所以发生这种情况,是因为空主体的值是
缺失值
,当您将其转换为字符串时,它将成为
“缺失值”
。为了避免这种情况,您可以在将提醒添加到
列表
之前明确检查提醒中缺少的值

repeat with i from 1 to (count of every reminder of list "Cities")
    set theReminder to reminder i of list "Cities"
    if theReminder is not completed then
        if the body of theReminder is not missing value then
            set theList to theList & {name, body} of theReminder
        else
            set theList to theList & {name of theReminder, ""}
        end if
     end if
 end repeat

如果你不想在没有正文的提醒之间有一个空行,你可以简单地在else子句中使用
{name of theReminder}

这是可行的,但是我如何将提醒的正文与名称放在同一行上呢。我可以把字符串连起来吗?当然可以。只需将提醒者的
{name,body}
替换为
(提醒者的名称和提醒者的“-”&body)
,然后去掉第二个字符串中的空字符串。