基础语法
一、这部分介绍注释,发出声音,弹窗
(1)简单入门
<1>多行注释 (* this is multi comment *) <2>发出响声 beep 3
(2)
#表示使用"Daniel"(英国发音)发出声音,人员选择如下图1所示 say "Hello,world" using "Daniel" --或用"--"也可以表示单行注释
图1
(3)弹窗
display alert "This is an alert" #弹窗示例
二、变量赋值,string和number类型,字符串连接
set varName3 to true #设置布尔值 set varName1 to "This is a string.And I love" #这是字符串值变量 set varName2 to "12" #设置数字变量把双引号去掉即可 set x to varName2 as number #转换整形字符串为整形 set y to 2 set z to varName2 * y --乘法运算 display dialog z --把乘积以弹窗的方式展示,结果为24 --字符串连接展示 set myCountry to " China." say varName1 & myCountry #把连接后的句子读出来
三、 lists
set varName to {"A1", "B2", "C3"} set varName2 to {"D4", "F5", "G6"} set item 1 of varName to "arun" set item -3 of varName2 to "arunyang.com" set anotherVarName to varName & varName2 #return anotherVarName set anotherVarName to items 2 through 2 of varName2 return anotherVarName