2012-10-25 117 views
2

我正在使用此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 三月拉斯维加斯 京都 访问2012年12月

回答

0

发生这种情况的原因是空体的值为missing value,当您将其转换为字符串时,该值为"missing value"。为避免这种情况,您可以在将其添加到theList之前明确检查提醒中是否缺少值。

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 

如果你不希望与任何机构提醒之间的空行,则可以简单地将其他子句中使用{name of theReminder}

+0

这有效,但我怎么会,但提醒的身体在同一行作为名称。我可以只串接字符串吗? – Jamie

+0

当然。只需用'(名称的提醒&“ - ”&提醒的主体“)替换提醒的'{name,body}',然后摆脱第二个空串。 – ughoavgfhw