Web edits
[beagleboard.org.git] / db / 2783.xml
blobdd22792a9633b6c468a7bcf0bb8dd070888d0ef2
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4   <hopobject id="2783" name="writeTextFile" prototype="Page" created="1371825643047" lastModified="1371825643063">
5   <hop:parent idref="2471" prototyperef="Page"/>
6     <is_xhtml type="boolean">true</is_xhtml>
7     <http_remotehost>127.0.0.1</http_remotehost>
8     <http_language>en-US,en;q=0.8</http_language>
9     <uri>writeTextFile</uri>
10     <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36</http_browser>
11     <time type="date">21.06.2013 09:40:43 CDT</time>
12     <hopsession>127.0.0.192.94.94.z5cudt01kfu3</hopsession>
13     <body>&lt;script src=&quot;/static/bonescript-demo.js&quot;&gt;&lt;/script&gt;\r
14 &lt;h2&gt;BonesSript&lt;/h2&gt;\r
16     &lt;div id=&apos;side-menu&apos; class=&quot;t3_sidebar&quot;&gt;\r
17      &lt;ul class=&quot;left-menu&quot;&gt;\r
18       &lt;strong&gt;Navigation&lt;/strong&gt;\r
19       &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/menu/&quot;&gt;Menu contents&lt;/a&gt;&lt;/li&gt;\r
20      &lt;/ul&gt;\r
21     &lt;/div&gt;\r
22     &lt;div class=&quot;t3_content_1&quot;&gt;\r
23      &lt;div id=&apos;connect-status&apos;&gt;&lt;/div&gt;\r
24      &lt;div id=&quot;content_child&quot;&gt;\r
25      &lt;!--- START CONTENT --&gt;\r
27 &lt;h1&gt;writeTextFile(filename, data, [callback])&lt;/h1&gt;\r
28 &lt;p&gt;Write the contents of a text (ASCII) file.&lt;/p&gt;\r
29 &lt;h2&gt;Arguments&lt;/h2&gt;\r
30 &lt;ul&gt;\r
31  &lt;li&gt;&lt;em&gt;filename&lt;/em&gt;: complete path of the file to be written&lt;/li&gt;\r
32  &lt;li&gt;&lt;em&gt;data&lt;/em&gt;: ASCII string to be written&lt;/li&gt;\r
33  &lt;li&gt;&lt;em&gt;callback&lt;/em&gt;: called upon completion&lt;/li&gt;\r
34 &lt;/ul&gt;\r
35 &lt;h2&gt;Return value&lt;/h2&gt;\r
36 &lt;h2&gt;callback(x)&lt;/h2&gt;\r
37 &lt;ul&gt;\r
38  &lt;li&gt;&lt;em&gt;x.err&lt;/em&gt;: error status message&lt;/li&gt;\r
39 &lt;/ul&gt;\r
40 &lt;h2&gt;Example\r
41  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
42  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
43 &lt;/h2&gt;\r
44 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height: 200px;&quot;&gt;\r
45 var b = require(&apos;bonescript&apos;);\r
46 var file = &apos;/sys/class/leds/beaglebone:green:usr3/trigger&apos;;\r
47 b.writeTextFile(file, &apos;heartbeat&apos;, readStatus);\r
48 function readStatus(x) {\r
49     console.log(JSON.stringify(x));\r
50     b.readTextFile(file, printStatus);\r
51 }\r
52 function printStatus(x) {\r
53     console.log(JSON.stringify(x));\r
54 }&lt;/pre&gt;\r
55 &lt;div readonly id=&apos;console-output&apos; style=&apos;height: 80px;&apos;&gt;&lt;/div&gt;\r
56 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
57 &lt;ul&gt;\r
58     &lt;li&gt;Be careful not to overwrite important files!&lt;/li&gt;\r
59     &lt;li&gt;Run the above to see the USR3 LED start to blink in a heartbeat pattern.&lt;/li&gt;\r
60     &lt;li&gt;Adjust the LED selection and trigger.&lt;/li&gt;\r
61 &lt;/ul&gt;\r
62 &lt;h2&gt;See also&lt;/h2&gt;\r
63 &lt;!--\r
64 &lt;h3&gt;Topics&lt;/h3&gt;\r
65 &lt;ul&gt;\r
66 &lt;/ul&gt;\r
67 --&gt;\r
68 &lt;h3&gt;Related functions&lt;/h3&gt;\r
69 &lt;ul&gt;\r
70  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
71  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/readTextFile/&quot;&gt;readTextFile&lt;/a&gt;&lt;/li&gt;\r
72 &lt;/ul&gt;\r
73 &lt;h3&gt;Examples&lt;/h3&gt;\r
74 &lt;ul&gt;\r
75  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/demo_bmp085/&quot;&gt;BMP085 I2C pressure/temperature sensor\r
76   demo&lt;/a&gt;&lt;/li&gt;\r
77  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/demo_bmp085_graphing/&quot;&gt;BMP085 I2C pressure/temperature\r
78   sensor graphing demo&lt;/a&gt;&lt;/li&gt;\r
79 &lt;/ul&gt;\r
81      &lt;!--- START FOOTER --&gt;\r
82      &lt;/div&gt;\r
83     &lt;/div&gt;\r
84     &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;</body>
85     <pseudoparent idref="2471" prototyperef="Page"/>
86     <http_referer>http://beagleboard.org/Support/BoneScript/writeTextFile/edit</http_referer>
87     <http_host>beagleboard.org</http_host>
88     <lang>en-us</lang>
89     <user>blog.hangerhead.com</user>
90   </hopobject>
91 </xmlroot>