[Ttssh2-commit] [4593] サンプルコード追加。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 8月 22日 (月) 18:12:48 JST


Revision: 4593
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4593
Author:   yutakapon
Date:     2011-08-22 18:12:48 +0900 (Mon, 22 Aug 2011)

Log Message:
-----------
サンプルコード追加。
cf.
http://logmett.com/forum/viewtopic.php?f=3&t=1771

Modified Paths:
--------------
    trunk/doc/en/html/macro/command/fileopen.html
    trunk/doc/en/html/macro/command/fileread.html
    trunk/doc/ja/html/macro/command/fileopen.html
    trunk/doc/ja/html/macro/command/fileread.html


-------------- next part --------------
Modified: trunk/doc/en/html/macro/command/fileopen.html
===================================================================
--- trunk/doc/en/html/macro/command/fileopen.html	2011-08-21 13:44:23 UTC (rev 4592)
+++ trunk/doc/en/html/macro/command/fileopen.html	2011-08-22 09:12:48 UTC (rev 4593)
@@ -26,7 +26,8 @@
 <p>
 Opens a file specified by &lt;file name&gt;.<br>
 If the file does not exist, it is created and then opened. If the file is successfully opened, the file handle is returned in the integer variable &lt;file handle&gt;. Otherwise, &lt;file handle&gt; is set to -1.<br>
-If &lt;append flag&gt; is zero, the file pointer is set to the beginning of the file. If &lt;append flag&gt; is non-zero, the file pointer is set to the end of the file.
+If &lt;append flag&gt; is zero, the file pointer is set to the beginning of the file. If &lt;append flag&gt; is non-zero, the file pointer is set to the end of the file.<br>
+Also, the file is opened in the binary mode.
 </p>
 
 <h2>Example</h2>
@@ -46,5 +47,10 @@
 end
 </pre>
 
+<h2>Reference</h2>
+
+<a href="filewrite.html">filewrite</a><br>
+<a href="fileclose.html">fileclose</a><br>
+
 </body>
 </html>

Modified: trunk/doc/en/html/macro/command/fileread.html
===================================================================
--- trunk/doc/en/html/macro/command/fileread.html	2011-08-21 13:44:23 UTC (rev 4592)
+++ trunk/doc/en/html/macro/command/fileread.html	2011-08-22 09:12:48 UTC (rev 4593)
@@ -27,7 +27,8 @@
 Reads specified byte data from the file specified by &lt;file handle&gt;.<br>
 The data are written into the string variable &lt;strvar&gt;. The file pointer is moved to reading bytes. <br>
 If the file pointer reaches the end of the file while reading the data, the system variable "result" is set to 1. Otherwise, "result" is set to zero.<br>
-The range of &lt;read byte&gt; argument must be from 1 to 255.
+The range of &lt;read byte&gt; argument must be from 1 to 255.<br>
+Also, a null character('\0) is added at the end of the string variable &lt;strvar&gt;.
 </p>
 
 <h2>Example</h2>
@@ -47,5 +48,39 @@
 fileclose fp
 </pre>
 
+<pre class="macro-example">
+; Send 32 bytes from a binary file.
+filename = 'sample.bin'
+
+fileopen fhandle filename 0
+if fhandle == -1 goto the_end
+
+call send_16_bytes      ; send first 16 bytes
+fileseek fhandle 16 1   ; seek past next 16 without sending
+call send_16_bytes      ; send next (last) 16 bytes
+fileclose fhandle
+goto the_end
+ 
+;#########################################
+:send_16_bytes
+    for i 1 16
+        fileread fhandle 1 str      ; read one byte at a time so we can detect zero.
+        if result == 1 break
+        str2code integer str        ; if zero then str will be empty and integer will be set to zero
+        ;sprintf 'integer = 0x%02X' integer
+        ;messagebox inputstr 'test'
+        send integer
+    next
+return
+;#########################################
+:the_end
+</pre>
+
+
+<h2>Reference</h2>
+
+<a href="fileopen.html">fileopen</a><br>
+<a href="fileclose.html">fileclose</a><br>
+
 </body>
 </html>

Modified: trunk/doc/ja/html/macro/command/fileopen.html
===================================================================
--- trunk/doc/ja/html/macro/command/fileopen.html	2011-08-21 13:44:23 UTC (rev 4592)
+++ trunk/doc/ja/html/macro/command/fileopen.html	2011-08-22 09:12:48 UTC (rev 4593)
@@ -26,7 +26,8 @@
 <p>
 ƒtƒ@ƒCƒ‹ &lt;filename&gt; ‚ðŠJ‚­B<br>
 ƒtƒ@ƒCƒ‹‚ª‘¶Ý‚µ‚È‚¢ê‡‚́AV‚½‚ɍ쐬‚³‚ê‚Ä‚©‚çƒI[ƒvƒ“‚³‚ê‚éB‚à‚µƒtƒ@ƒCƒ‹‚ª³‚µ‚­ƒI[ƒvƒ“‚³‚ꂽê‡Aƒtƒ@ƒCƒ‹ƒnƒ“ƒhƒ‹‚ª®”•Ï” &lt;file handle&gt; ‚ÉŠi”[‚³‚ê‚éB‚»‚êˆÈŠO‚̏ꍇA&lt;file handle&gt; ‚É-1‚ªŠi”[‚³‚ê‚éB<br>
-&lt;append flag&gt; ‚ª0‚̏ꍇAƒtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚̈ʒu‚̓tƒ@ƒCƒ‹‚ÌŽn‚߂ɃZƒbƒg‚³‚ê‚éB&lt;append flag&gt; ‚ª0ˆÈŠO‚̏ꍇAƒtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚̓tƒ@ƒCƒ‹‚̍Ōã‚ɃZƒbƒg‚³‚ê‚éB
+&lt;append flag&gt; ‚ª0‚̏ꍇAƒtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚̈ʒu‚̓tƒ@ƒCƒ‹‚ÌŽn‚߂ɃZƒbƒg‚³‚ê‚éB&lt;append flag&gt; ‚ª0ˆÈŠO‚̏ꍇAƒtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚̓tƒ@ƒCƒ‹‚̍Ōã‚ɃZƒbƒg‚³‚ê‚éB<br>
+‚È‚¨Aƒtƒ@ƒCƒ‹‚̓oƒCƒiƒŠƒ‚[ƒh‚ŃI[ƒvƒ“‚³‚ê‚éB
 </p>
 
 <h2>—á</h2>
@@ -46,5 +47,10 @@
 end
 </pre>
 
+<h2>ŽQÆ</h2>
+
+<a href="filewrite.html">filewrite</a><br>
+<a href="fileclose.html">fileclose</a><br>
+
 </body>
 </html>

Modified: trunk/doc/ja/html/macro/command/fileread.html
===================================================================
--- trunk/doc/ja/html/macro/command/fileread.html	2011-08-21 13:44:23 UTC (rev 4592)
+++ trunk/doc/ja/html/macro/command/fileread.html	2011-08-22 09:12:48 UTC (rev 4593)
@@ -27,7 +27,8 @@
 &lt;file handle&gt; ‚É‚æ‚èŽw’肳‚ꂽƒtƒ@ƒCƒ‹‚©‚ç“Á’肵‚½ƒoƒCƒg”‚̃f[ƒ^‚ð“ǂݏo‚·B<br>
 ƒf[ƒ^‚Í•¶Žš—ñ•Ï” &lt;strvar&gt; ‚Ö‹L‰¯‚³‚êAƒtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚͓ǂݍž‚ñ‚¾ƒoƒCƒg”•ªi‚ß‚ç‚ê‚éB<br>
 ƒf[ƒ^‚ð“ǂݍž‚ݏI‚í‚é‘O‚Ƀtƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^‚ªƒtƒ@ƒCƒ‹‚̏I‚í‚è‚܂ōs‚Á‚½ê‡‚́AƒVƒXƒeƒ€•Ï” "result" ‚É 1 ‚ªŠi”[‚³‚ê‚éB ‚»‚êˆÈŠO‚́A"result" ‚É 0 ‚ªŠi”[‚³‚ê‚éB<br>
-•Ï” &lt;read byte&gt; ‚Ì‚Æ‚é’l‚Ì”ÍˆÍ‚Í 1 ‚©‚ç 255 ‚Å‚È‚¯‚ê‚΂Ȃç‚È‚¢B
+•Ï” &lt;read byte&gt; ‚Ì‚Æ‚é’l‚Ì”ÍˆÍ‚Í 1 ‚©‚ç 255 ‚Å‚È‚¯‚ê‚΂Ȃç‚È‚¢B<br>
+‚È‚¨A•¶Žš—ñ•Ï” &lt;strvar&gt; ‚Ì––”ö‚Í '\0' ‚ª•t‰Á‚³‚ê‚éB
 </p>
 
 <h2>—á</h2>
@@ -47,5 +48,38 @@
 fileclose fp
 </pre>
 
+<pre class="macro-example">
+; ƒoƒCƒiƒŠƒtƒ@ƒCƒ‹‚̐擪‚©‚ç32ƒoƒCƒg‚ð“ǂݍž‚݁AƒzƒXƒg‚Ö‘—M‚·‚éB
+filename = 'sample.bin'
+
+fileopen fhandle filename 0
+if fhandle == -1 goto the_end
+
+call send_16_bytes      ; send first 16 bytes
+fileseek fhandle 16 1   ; seek past next 16 without sending
+call send_16_bytes      ; send next (last) 16 bytes
+fileclose fhandle
+goto the_end
+ 
+;#########################################
+:send_16_bytes
+    for i 1 16
+        fileread fhandle 1 str      ; read one byte at a time so we can detect zero.
+        if result == 1 break
+        str2code integer str        ; if zero then str will be empty and integer will be set to zero
+        ;sprintf 'integer = 0x%02X' integer
+        ;messagebox inputstr 'test'
+        send integer
+    next
+return
+;#########################################
+:the_end
+</pre>
+
+<h2>ŽQÆ</h2>
+
+<a href="fileopen.html">fileopen</a><br>
+<a href="fileclose.html">fileclose</a><br>
+
 </body>
 </html>



Ttssh2-commit メーリングリストの案内
Back to archive index