applescript - 无法输入数字类型

gad*_*tmo 1 string applescript numbers

为什么这个简单的 Applescript 片段不起作用?

\n\n
set x to 0\nset thePath to "~/Pictures/party hard/b93-" + x + ".png"\n
Run Code Online (Sandbox Code Playgroud)\n\n

我收到错误:

\n\n
Can\xe2\x80\x99t make "~/Pictures/party hard/b93-" into type number.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我尝试过很多其他的事情,比如(x as string)

\n\n

这么简单,我不明白为什么它不起作用。

\n

rob*_*lls 5

AppleScript\xe2\x80\x99s 连接运算符是&,而按+字面解释。它会引发错误,因为您的代码正在尝试将字符串和数字相加。

\n\n

尝试这个:

\n\n
set x to 0\nset thePath to "~/Pictures/party hard/b93-" & x & ".png"\n
Run Code Online (Sandbox Code Playgroud)\n