我正在尝试使用 Applescript 处理来自一个工作表的输入,以创建另一个具有特定名称的工作表。我可以毫无问题地创建新工作表,但如果我运行脚本两次,它(适当地)给我一个错误,因为具有该名称的工作表已经存在。
这是我尝试过的,但它在 if 语句上给了我一个错误('Can't get sheet who name = "[the value of nextTuesdaysName]"'):
set nextTuesday to current date
repeat until nextTuesday's weekday is Tuesday
set nextTuesday to nextTuesday + days
end repeat
set {year:nextTuesdaysYear, month:nextTuesdaysMonth, day:nextTuesdaysDay} to nextTuesday
set nextTuesdaysName to "Tuesday " & (nextTuesdaysYear * 10000 + nextTuesdaysMonth * 100 + nextTuesdaysDay as string)
tell application "Numbers"
tell document 1
if (sheet whose name is nextTuesdaysName) exists then
display dialog "There's already a worksheet named '" &
nextTuesdaysName & "'" buttons {"Quit", "Replace"} default button 2 with icon 1
# delete (first sheet whose name is nextTuesdaysName)
end if
set thisSheet to make new sheet with properties {name:nextTuesdaysName}
end tell
end tell
如何构造 if 语句以检查命名工作表是否存在?
TIA