{"id":36,"date":"2016-09-14T13:38:16","date_gmt":"2016-09-14T05:38:16","guid":{"rendered":"http:\/\/45.76.100.195\/?p=36"},"modified":"2016-09-14T13:38:16","modified_gmt":"2016-09-14T05:38:16","slug":"%e6%b5%81%e7%a8%8b%e6%8e%a7%e5%88%b6%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/www.carnica.cn\/?p=36","title":{"rendered":"\u6d41\u7a0b\u63a7\u5236\u8bed\u53e5"},"content":{"rendered":"<h2>Tell \u8bed\u53e5<\/h2>\n<p>Tell\u8bed\u53e5\u662f\u6700\u65e9\u63a5\u89e6\uff0c\u4e14\u6700\u91cd\u8981\u7684\u6d41\u7a0b\u63a7\u5236\u8bed\u53e5\u3002\u5b83\u7684\u4f5c\u7528\u662f\u6307\u660e\u811a\u672c\u8981\u63a7\u5236\u7684\u7a0b\u5e8f\u5bf9\u8c61\u3002<br \/>\nTell\u8bed\u53e5\u5177\u6709\u4e24\u79cd\u8bed\u6cd5\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>\u7b80\u5355\u5f62\u5f0f\uff1a tell referenceToObject to statement<\/li>\n<li>\u590d\u5408\u5f62\u5f0f\uff1a \u4ee5 \u201ctell referenceToObject\u201d \u5f00\u59cb\uff0c\u201cend tell\u201d \u7ed3\u5c3e\u3002\u4e2d\u95f4\u5305\u542b\u547d\u4ee4\u8bed\u53e5\u3002<\/li>\n<\/ul>\n<p>\u5176\u4e2d\uff1a referenceToObject\u4e3a\u9700\u8981\u63a7\u5236\u7684\u5bf9\u8c61\uff0c\u5982\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u3001\u4e00\u4e2a\u7a97\u53e3\u3002 statement \u4e3a\u547d\u4ee4\u8bed\u53e5\uff0c\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u547d\u4ee4\u3002<\/p>\n<p>\u4e0b\u9762\u5b9e\u4f8b\u5c06\u5173\u95edFinder\u7a0b\u5e8f\u4e2d\u4f4d\u4e8e\u6700\u524d\u7684\u7a97\u53e3\uff0c\u5c06\u4f7f\u7528\u4e86\u4e24\u79cd\u5f62\u5f0f\u7684Tell\u8bed\u53e5\uff0c\u4e24\u79cd\u5f62\u5f0f\u4f5c\u7528\u7ed3\u679c\u76f8\u540c\u3002<\/p>\n<pre><code>tell front window of application \"Finder\" to close\r\n--\u8fd9\u662f\u7b80\u5355\u5f62\u5f0f\r\n\r\ntell application \"Finder\"\r\n \u00a0 \u00a0close front window\r\nend tell\r\n--\u8fd9\u662f\u590d\u5408\u5f62\u5f0f\r\n\r\n\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528Tell\u8bed\u53e5\u7684\u590d\u5408\u5f62\u5f0f\u8f83\u4e3a\u5e38\u89c1\uff0c\u4e5f\u4fbf\u4e8e\u9605\u8bfb\u3002\r\n<\/code><\/pre>\n<h2>If \u6761\u4ef6\u8bed\u53e5<\/h2>\n<p>If\u8bed\u53e5\u7528\u4e8e\u5728\u6ee1\u8db3\u4e00\u5b9a\u6761\u4ef6\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u8bed\u53e5\uff0c\u6216\u8005\u4f9d\u636e\u6761\u4ef6\u5b9e\u73b0\u7a0b\u5e8f\u6d41\u7a0b\u8df3\u8f6c\u3002<\/p>\n<ul class=\" list-paddingleft-2\">\n<li>\u7b80\u5355\u5f62\u5f0f\uff1a\n<pre><code> \u00a0if boolean then statement\r\n<\/code><\/pre>\n<\/li>\n<li>\u590d\u5408\u5f62\u5f0f\uff1a\n<pre><code> \u00a0if boolean1 then\r\n \u00a0 \u00a0 \u00a0statement1\r\n \u00a0else if boolean2 then\r\n \u00a0 \u00a0 \u00a0statement2\r\n \u00a0else\r\n \u00a0 \u00a0 \u00a0statement3\r\n \u00a0end if\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>\u8be5\u590d\u5408\u5f62\u5f0f\u7a0b\u5e8f\u6d41\u7a0b\u5982\u4e0b\uff1a\u00a0<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/i1.buimg.com\/567571\/28146956d31f5e59.png\" alt=\"\" width=\"580\" height=\"150\" \/><br \/>\n\u5176\u4e2d\uff1aboolean\u4e3aBoolean\u6570\u636e\uff0c\u6216\u8005\u5224\u65ad\u8bed\u53e5\uff08\u8fd4\u56detrue\u6216false\uff09\u3002\u00a0<strong>if\u8bed\u53e5\u4e2d\uff0c\u53ef\u4ee5\u6709\u591a\u4e2aelse if\uff0c\u4f46\u81f3\u591a\u53ea\u80fd\u6709\u4e00\u4e2aelse\uff08\u53ef\u4ee5\u6ca1\u6709\uff09<\/strong>\u3002<\/p>\n<p>\u4e0b\u9762\u5b9e\u4f8b\u5c06\u6839\u636e\u53d8\u91cfmark\u7684\u503c\uff0c\u6765\u663e\u793a\u76f8\u5e94\u7684\u5bf9\u8bdd\u6846\u3002<\/p>\n<pre><code>set mark to 99 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0--\u4fee\u6539\u8fd9\u91cc\u7684\u6570\u636e\u6765\u89c2\u5bdf\u7ed3\u679c\r\nif mark \u2265 60 and mark &lt; 80 then\r\n \u00a0 \u00a0set response to \"You passed the exam\"\r\nelse if mark \u2265 80 then\r\n \u00a0 \u00a0set response to \"Congratulations! You're smart.\"\r\nelse\r\n \u00a0 \u00a0set response to \"Sorry. You failed\"\r\nend if\r\n\r\ndisplay dialog response\r\n<\/code><\/pre>\n<h2>\u5faa\u73af\u8bed\u53e5<\/h2>\n<p>\u5728AppleScript\u4e2d\uff0c\u5faa\u73af\u7684\u529f\u80fd\u975e\u5e38\u5f3a\u5927\uff0c\u63d0\u4f9b\u4e86\u81f3\u5c11\u516d\u79cd\u5faa\u73af\u65b9\u5f0f\u3002<\/p>\n<h4>\u9000\u51fa\u5faa\u73af\u7684\u547d\u4ee4<\/h4>\n<p>\u9000\u51fa\u5faa\u73af\u7684\u547d\u4ee4\u975e\u5e38\u7b80\u5355\uff1aexit\uff08\u5b8c\u6574\u7684\u4e3aexit repeat\uff09\u3002\u00a0<strong><em>\u8bf7\u7262\u8bb0<\/em><\/strong><br \/>\n\u9664\u4e86exit\u53ef\u4ee5\u5f3a\u5236\u9000\u51fa\u5faa\u73af\u5916\uff0creturn\u4e5f\u53ef\u4ee5\u8d77\u5230\u9000\u51fa\u5faa\u73af\u7684\u4f5c\u7528\uff0c\u4f46\u662f<strong>return\u7684\u5b9e\u9645\u610f\u4e49\u662f\u9000\u51fa\u5f53\u524d\u7684\u4e8b\u4ef6\u5904\u7406\u5668\uff0c\u8fd4\u56de\u811a\u672c\u6d41\u7a0b\u3002<\/strong><\/p>\n<h4>\u65e0\u9650\u5faa\u73af<\/h4>\n<p>\u8fd9\u662f\u6700\u7b80\u5355\u7684\u5faa\u73af\uff0c\u4f46\u662f\u8bf7<strong><em>\u614e\u91cd\u4f7f\u7528<\/em><\/strong>\uff01\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>repeat\r\n \u00a0 \u00a0--do something\r\nend repeat\r\n<\/code><\/pre>\n<p><strong><em>\u52a1\u5fc5\u5728\u65e0\u9650\u5faa\u73af\u8bed\u53e5\u4e2d\u5305\u542bexit\u547d\u4ee4\uff08\u5f53\u7136\uff0cexit\u5305\u542b\u5728if\u8bed\u53e5\u4e2d\u624d\u662f\u6b63\u786e\u7684\uff09<\/em><\/strong><\/p>\n<h4>\u9650\u5b9a\u6b21\u6570\u5faa\u73af<\/h4>\n<p>\u8bed\u6cd5\u4e2d\u7684\u201cn\u201d\u6307\u5b9a\u4e86\u5faa\u73af\u591a\u5c11\u6b21\u3002\u00a0<strong>\u201cn\u201d\u5fc5\u987b\u4e3a\u6574\u6570\u6216\u8005\u6574\u578b\u6570\u636e\uff0c\u4e14\u5927\u4e8e\u7b49\u4e8e1.<\/strong><\/p>\n<pre><code>repeat n times\r\n \u00a0 \u00a0--do something\r\nend repeat\r\n<\/code><\/pre>\n<h4>\u201c\u76f4\u5230\u201d\u5faa\u73af<\/h4>\n<pre><code>repeat until boolean\r\n \u00a0 \u00a0--do something\r\nend repeat\r\n<\/code><\/pre>\n<p>\u5faa\u73af\u5c06\u53cd\u590d\u6267\u884c\uff0c\u76f4\u5230boolean\u4e3a\u771f\uff01 \u4e5f\u5c31\u662f\u8bf4\uff0cboolean\u4e3a\u5047\u7684\u65f6\u5019\u5faa\u73af\u6267\u884c\uff0c\u4e00\u65e6boolean\u4e3a\u771f\uff0c\u9000\u51fa\u5faa\u73af\u3002<\/p>\n<h4>\u201c\u5f53\u201d\u5faa\u73af<\/h4>\n<pre><code>repeat while boolean\r\n \u00a0 \u00a0--do something\r\nend repeat\r\n<\/code><\/pre>\n<p>\u5f53boolean\u4e3a\u771f\u65f6\uff0c\u5faa\u73af\u53cd\u590d\u6267\u884c\uff0c\u4e00\u65e6boolean\u4e3a\u5047\uff0c\u9000\u51fa\u5faa\u73af\u3002<br \/>\n<strong><em>\u201c\u76f4\u5230\u201d\u5faa\u73af \u548c \u201c\u5f53\u201d\u5faa\u73af \u5728\u4e00\u5b9a\u610f\u4e49\u4e0a\u662f\u6b63\u597d\u76f8\u53cd\u7684\u3002<\/em><\/strong><\/p>\n<h4>\u53d8\u91cf\u5faa\u73af<\/h4>\n<pre><code>repeat with loopVariable from startValue to stopValue by stepValue\r\n \u00a0 \u00a0--do something\r\nend repeat \r\n<\/code><\/pre>\n<p>\u5176\u4e2dstepValue\u53ef\u7701\u7565\uff0c\u7701\u7565\u65f6\u4e3a\u9ed8\u8ba4\u503c\u201c1\u201d\uff1bloopVariable\u65e0\u9700\u4e8b\u5148\u5b9a\u4e49\u3002<br \/>\n\u5176\u6267\u884c\u6d41\u7a0b\u5982\u4e0b\u56fe\uff0c\u8bf7\u6ce8\u610f\u5404\u4e2a\u53d8\u91cf\u7684\u7528\u9014\uff1a\u00a0<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/i2.buimg.com\/567571\/30d548263a7fdd74.png\" alt=\"\" width=\"600\" height=\"150\" \/><br \/>\n\u8fd9\u79cd\u5faa\u73af\u7528\u4e8e\u7cbe\u786e\u63a7\u5236\u5faa\u73af\u6b21\u6570\uff0c\u6216\u8005\u662f\u548c\u5faa\u73af\u53d8\u91cf\u672c\u8eab\u6709\u5173\u7684\u5faa\u73af\u3002<\/p>\n<h4>List\u7c7b\u578b\u6570\u636e\u5faa\u73af<\/h4>\n<p>\u8fd9\u4e2a\u5faa\u73af\u8f83\u4e3a\u590d\u6742\u3002<\/p>\n<pre><code>repeat with loopVariable in list\r\n \u00a0 \u00a0--do something\r\nend repeat\r\n<\/code><\/pre>\n<p>\u5176\u4e2dloopVariable\u65e0\u9700\u4e8b\u5148\u5b9a\u4e49\uff0clist\u662fList\u578b\u6216\u8005Record\u578b\u6570\u636e\u3002<br \/>\n\u5728\u5faa\u73af\u4f53\u4e2d\uff0cloopVariable\u5c06\u4f9d\u6b21\u5f97\u5230item 1 of list, item 2 of list...\u8fd9\u6837\u7684\u6307\u9488\uff08\u6307\u5411list\u4e2d\u7684\u7b2c\u51e0\u9879\uff09\u3002 \u8bf7\u7279\u522b\u6ce8\u610f\u662f<strong><em>\u6307\u9488<\/em><\/strong>\uff01\u5982\u679c\u8981\u5f97\u5230list\u4e2d\u7684\u5177\u4f53\u5185\u5bb9\uff0c\u4f7f\u7528<em>contents of loopVariable<\/em>\u6765\u83b7\u5f97\u3002<br \/>\n\u5728\u8fd9\u4e2a\u5faa\u73af\u91cc\uff0c\u5faa\u73af\u4f53\u5c06\u6267\u884c\u548clist\u9879\u76ee\u6570\u91cf\u4e00\u6837\u7684\u6b21\u6570\u3002<br \/>\n\u4e3a\u4e86\u5177\u4f53\u8bf4\u660e\uff0c\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><code>set myList to {\"Hello\",\"Hi\",\"Hey\",\"Goodbye\"} \u00a0 --\u5b9a\u4e49\u4e00\u4e2aList\r\n\r\n--\u5faa\u73af\u5f00\u59cb\r\nrepeat with i in myList\r\n \u00a0 \u00a0display dialog (contents of i) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0--\u663e\u793a\u4e00\u4e2a\u5305\u542bList\u4e2d\u5f53\u524d\u6307\u5411\u9879\u76ee\u7684\u5185\u5bb9\u7684\u5bf9\u8bdd\u6846\r\n \u00a0 \u00a0set (contents of i) to \"oh\" \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 --\u4fee\u6539List\u4e2d\u5f53\u524d\u6307\u5411\u9879\u76ee\u4e3a\u201coh\u201d\r\nend repeat\r\n<\/code><\/pre>\n<h2>Considering\/Ignoring\u8bed\u53e5\uff08\u7528\u4e8e\u6587\u672c\u6bd4\u8f83\uff09<\/h2>\n<p>\u6b64\u8bed\u53e5\u53ef\u4ee5\u5728\u6bd4\u8f83\u6587\u672c\u65f6\uff0c\u6307\u5b9a\u5ffd\u7565\u6216\u8003\u8651\u67d0\u4e00\u5c5e\u6027\uff08\u5982\uff1a\u5927\u5c0f\u5199\u3001\u7a7a\u683c\u7b49\u7b49\uff09\u3002<\/p>\n<pre><code>considering attribute1 but ignoring attribute2\r\n \u00a0 \u00a0--compare texts\r\nend considering\r\n<\/code><\/pre>\n<p>\u4e0a\u9762\u4ee3\u7801\u542b\u4e49\u662f\u8003\u8651attribute1\uff0c\u4f46\u5ffd\u7565attribute2\u3002<br \/>\n\u5176\u4e2d but ignoring attribute2 \u53ef\u4ee5\u7701\u7565\u3002<br \/>\n<strong>considering\u548cignoring\u4f4d\u7f6e\u53ef\u4ee5\u4e92\u6362\uff0c\u4f46\u662fend considering\u4e5f\u8981\u76f8\u5e94\u6539\u6210end ignoring\u3002\u5f53\u7136\u4e5f\u53ef\u4ee5\u9009\u62e9\u6700\u7b80\u7565\u7684\u65b9\u5f0f---\u53ea\u8f93\u5165end\uff0c\u8ba9\u7f16\u8bd1\u5668\u81ea\u5df1\u4e0d\u4e0aconsidering\/ignoring\u3002<\/strong><\/p>\n<p>attribute\u5e94\u8be5\u4e3a\u4e0b\u9762\u5217\u8868\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\uff1a<\/p>\n<ul class=\" list-paddingleft-2\">\n<li><code>case<\/code>\u00a0\u5927\u5c0f\u5199<\/li>\n<li><code>diacriticals<\/code>\u00a0\u5b57\u6bcd\u53d8\u8c03\u7b26\u53f7\uff08\u5982\uff1ae \u548c \u00e9\uff09<\/li>\n<li><code>hyphens<\/code>\u00a0\u8fde\u5b57\u7b26\uff08-\uff09<\/li>\n<li><code>numeric strings<\/code>\u00a0\u6570\u5b57\u5316\u5b57\u7b26\u4e32\uff08\u9ed8\u8ba4\u662f\u5ffd\u7565\u7684\uff09\uff0c\u7528\u4e8e\u6bd4\u8f83\u7248\u672c\u53f7\u65f6\u542f\u7528\u5b83<\/li>\n<li><code>punctuation<\/code>\u00a0\u6807\u70b9\u7b26\u53f7\uff08,.?!\u7b49\u7b49\uff0c\u5305\u62ec\u4e2d\u5348\u6807\u70b9\uff09<\/li>\n<li><code>white space<\/code>\u00a0\u7a7a\u683c<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Tell \u8bed\u53e5 Tell\u8bed\u53e5\u662f\u6700\u65e9\u63a5\u89e6\uff0c\u4e14\u6700\u91cd\u8981&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":1,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions\/37"}],"wp:attachment":[{"href":"https:\/\/www.carnica.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.carnica.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}