2013-01-20 19 views
1

爲什麼這個簡單的Applescript代碼段不起作用?蘋果腳本 - 不能編入類型編號

set x to 0 
set thePath to "~/Pictures/party hard/b93-" + x + ".png" 

我得到的錯誤:

Can’t make "~/Pictures/party hard/b93-" into type number. 

我已經嘗試了很多其他的東西,比如(x as string)

這很簡單,我不明白爲什麼它不起作用。

回答

4

AppleScript的連接運算符是&,而+是字面解釋。它會拋出一個錯誤,因爲你的代碼試圖添加一個字符串和一個數字在一起。

試試這個:

set x to 0 
set thePath to "~/Pictures/party hard/b93-" & x & ".png" 
+0

謝謝!我只是習慣於用其他語言編程,我暫時還沒有使用過Applescript。 – gadgetmo