Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/doc/en/html/macro/command/fileread.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5266 - (show annotations) (download) (as text)
Fri May 17 13:45:05 2013 UTC (6 days, 3 hours ago) by doda
File MIME type: text/html
File size: 2250 byte(s)
文字列変数の最大長の変更に合わせてマニュアルを修正
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <title>fileread</title>
7 <meta http-equiv="Content-Style-Type" content="text/css">
8 <link rel="stylesheet" href="../../style.css" type="text/css">
9 </head>
10
11 <body>
12
13
14 <h1>fileread</h1>
15
16 <p>
17 Reads a file.
18 </p>
19
20 <pre class="macro-syntax">
21 fileread &lt;file handle&gt; &lt;read byte&gt; &lt;strvar&gt;
22 </pre>
23
24 <h2>Remarks</h2>
25
26 <p>
27 Reads specified byte data from the file specified by &lt;file handle&gt;.<br>
28 The data are written into the string variable &lt;strvar&gt;. The file pointer is moved to reading bytes. <br>
29 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>
30 The range of &lt;read byte&gt; argument must be from 1 to 511.<br>
31 Also, a null character('\0) is added at the end of the string variable &lt;strvar&gt;.
32 </p>
33
34 <h2>Example</h2>
35
36 <pre class="macro-example">
37 filename = 'foo.txt'
38
39 fileopen fp filename 0
40
41 :loop
42 <strong>fileread</strong> fp 10 data
43 messagebox data filename
44 if result goto fclose
45 goto loop
46
47 :fclose
48 fileclose fp
49 </pre>
50
51 <pre class="macro-example">
52 ; Send 32 bytes from a binary file.
53 filename = 'sample.bin'
54
55 fileopen fhandle filename 0
56 if fhandle == -1 goto the_end
57
58 call send_16_bytes ; send first 16 bytes
59 fileseek fhandle 16 1 ; seek past next 16 without sending
60 call send_16_bytes ; send next (last) 16 bytes
61 fileclose fhandle
62 goto the_end
63
64 ;#########################################
65 :send_16_bytes
66 for i 1 16
67 fileread fhandle 1 str ; read one byte at a time so we can detect zero.
68 if result == 1 break
69 str2code integer str ; if zero then str will be empty and integer will be set to zero
70 ;sprintf 'integer = 0x%02X' integer
71 ;messagebox inputstr 'test'
72 send integer
73 next
74 return
75 ;#########################################
76 :the_end
77 </pre>
78
79
80 <h2>Reference</h2>
81
82 <a href="fileopen.html">fileopen</a><br>
83 <a href="fileclose.html">fileclose</a><br>
84
85 </body>
86 </html>

SourceForge.JP is a Japanese version of SourceForge.net. For developments that are not related to Japan, we recommend you to use SourceForge.net.