{"id":155,"date":"2008-10-11T14:13:41","date_gmt":"2008-10-11T19:13:41","guid":{"rendered":"http:\/\/vgable.com\/blog\/2008\/10\/11\/an-applescript-quine\/"},"modified":"2009-09-25T22:12:00","modified_gmt":"2009-09-26T03:12:00","slug":"an-applescript-quine","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2008\/10\/11\/an-applescript-quine\/","title":{"rendered":"An AppleScript Quine"},"content":{"rendered":"<p><a href=\"http:\/\/vgable.com\/code\/quine.applescript.zip\">Here<\/a> is my first <a href=\"http:\/\/www.madore.org\/~david\/computers\/quine.html\">quine<\/a>.  It&#8217;s written in AppleScript, because I wasn&#8217;t <a href=\"http:\/\/www.nyx.net\/~gthompso\/quine.htm\">able to find<\/a>, another AppleScript quine.<\/p>\n<p>When run <a href=\"http:\/\/vgable.com\/code\/quine.applescript.zip\">quine.applescript<\/a> will make Script Editor create a new window containing the source code.  It&#8217;s particularly meta if you use Script Editor (the default application) to run the quine, because it&#8217;s not just printing itself, it&#8217;s writing itself in the IDE!<\/p>\n<p>Fortunately, <a href=\"http:\/\/imlocation.wordpress.com\/2007\/11\/03\/an-applescript-quine\/\">the problems I&#8217;d originally had with Script Editor and the quine<\/a> seem to have been fixed.<\/p>\n<p>EDITED TO ADD: Here&#8217;s the quine&#8217;s source, but you really should <a href=\"http:\/\/vgable.com\/code\/quine.applescript.zip\">download it<\/a> to run it, because wordpress has a habit of subtly mucking with copied code\u2026<\/p>\n<pre>\nset d to \"on string_from_ASCII_numbers(x)\n\tset s to ASCII character of item 1 of x\n\trepeat with i from 2 to number of items in x\n\t\tset s to s & (ASCII character of item i of x)\n\tend repeat\nend string_from_ASCII_numbers\nset set_d_to to {115, 101, 116, 32, 100, 32, 116, 111, 32}\nset scriptEditor to {83, 99, 114, 105, 112, 116, 32, 69, 100, 105, 116, 111, 114}\nset quine to string_from_ASCII_numbers(set_d_to) & quote & d & quote & return & d\ntell application string_from_ASCII_numbers(scriptEditor) to make new document with properties {contents:quine}\"\non string_from_ASCII_numbers(x)\n\tset s to ASCII character of item 1 of x\n\trepeat with i from 2 to number of items in x\n\t\tset s to s & (ASCII character of item i of x)\n\tend repeat\nend string_from_ASCII_numbers\nset set_d_to to {115, 101, 116, 32, 100, 32, 116, 111, 32}\nset scriptEditor to {83, 99, 114, 105, 112, 116, 32, 69, 100, 105, 116, 111, 114}\nset quine to string_from_ASCII_numbers(set_d_to) & quote & d & quote & return & d\ntell application string_from_ASCII_numbers(scriptEditor) to make new document with properties {contents:quine}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is my first quine. It&#8217;s written in AppleScript, because I wasn&#8217;t able to find, another AppleScript quine. When run quine.applescript will make Script Editor create a new window containing the source code. It&#8217;s particularly meta if you use Script Editor (the default application) to run the quine, because it&#8217;s not just printing itself, it&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,4,11],"tags":[45,204],"class_list":["post-155","post","type-post","status-publish","format-standard","hentry","category-announcement","category-programming","category-research","tag-apple-script","tag-quine"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=155"}],"version-history":[{"count":2,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}