OSx AppleScript簡單入門

OSx AppleScript簡單入門

OSx AppleScript簡單入門

運行結果

註釋

與c語言區別不大

-- 註釋一行

# 註釋一行

(???) 註釋多行

錯誤捕獲

意外的終止是我們所不希望的。比如,你的腳本需要打開一個文件夾處理其中的文件, 但是這個文件夾已經被刪除了,你會希望腳本允許用戶選擇其它合適的文件夾,而不是意外退出。

你可以把這些可能引起運行錯

誤的語句放入“try...end try”模塊中

try set x to 1 / 0on error the error_message number the error_number display dialog "Error: " & the error_number & "." & the error_message buttons {"OK"}end try

變量轉型

那麼number對你真的一點挑戰性都沒有。

OSx AppleScript簡單入門

數值類型

字符串也都是變量,它們是可以用&拼接的,還有一些其他的玩法。

OSx AppleScript簡單入門

字符串之一

OSx AppleScript簡單入門

字符串之二

分割,組合,轉化,字符串的玩法還是蠻多的。

list的使用和數組一樣,就是增,刪,改,查


分享到:


相關文章: