如何在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 

我收到一条错误消息:如何在AppleScript中将字符串与日期编号组合?

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

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

set targetMessage to "Laptop logged in at " & timestamp 

错误消息是有道理的。它认为你试图将该字符串添加到数字中,因此将其强制转换为数字失败。

+0

这工作。我感谢你的帮助。 @jweaks。 –