如何在AppleScript中将字符串与日期编号组合?

时间:2016-11-07 17:08:28

标签: macos timestamp applescript

set targetMessage to "Laptop logged in at" + timestamp
tell application "Messages"
    set targetService to 1st service whose service type = iMessage
    set targetBuddy to buddy targetBuddyPhone of targetService
    send targetMessage to targetBuddy
end tell

我收到一条错误消息:

error "Can’t make \"Laptop logged in at\" into type number." number -1700 from "Laptop logged in at" to number

1 个答案:

答案 0 :(得分:0)

你有一个拼写错误(实际上是其他语言的遗物)。你的第一行应该使用&组合字符串。

cut

错误消息有意义。它以为你试图将字符串添加到数字中,因此将其强制转换为数字失败。