2016-11-07 38 views
0
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 

回答

0

你有一個錯字(實際上是從其他語言的遺蹟)。你的第一行應該使用&來組合字符串。

set targetMessage to "Laptop logged in at " & timestamp 

錯誤消息是有道理的。它認爲你試圖將該字符串添加到數字中,因此將其強制轉換爲數字失敗。

+0

這工作。我感謝你的幫助。 @jweaks。 –

相關問題