$fread: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Mhh |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Returns the next $crlf delimited line or the number of bytes read into the specified binary variable, where M is the number of bytes to read. | |||
$fread(name | N[,M, &binvar]) | |||
If you do not specify M and &binvar, it will return everything until the next $crlf. | |||
== Example == | |||
At first, we have a file called ''moo.txt'' in our mircdir: | |||
one | |||
two | |||
three | |||
We've opened it with ''[[fopen]] moo moo.txt''. | |||
$fread( | |||
[[echo]] -a $fread(moo) | |||
This will echo ''one'' to your active window, as the pointer is set to the begin of the first line and read until the end. | |||
echo -a [[$fgetc]](moo) | |||
echo -a $fread(moo) | |||
The first command will echo the first char of line two (''t''), the second one everything from this ''t'' to the end of the line, so: ''wo''. | |||
echo -a $fread(moo,5,&mybinvar) | |||
This will echo 5, as 5 bytes (''three'', it's the entire third line) were read into the binvar called &mybinvar. | |||
[[Category:File Handling]] |
Latest revision as of 16:58, 19 December 2005
Returns the next $crlf delimited line or the number of bytes read into the specified binary variable, where M is the number of bytes to read.
$fread(name | N[,M, &binvar])
If you do not specify M and &binvar, it will return everything until the next $crlf.
Example
At first, we have a file called moo.txt in our mircdir:
one two three
We've opened it with fopen moo moo.txt.
echo -a $fread(moo)
This will echo one to your active window, as the pointer is set to the begin of the first line and read until the end.
echo -a $fgetc(moo) echo -a $fread(moo)
The first command will echo the first char of line two (t), the second one everything from this t to the end of the line, so: wo.
echo -a $fread(moo,5,&mybinvar)
This will echo 5, as 5 bytes (three, it's the entire third line) were read into the binvar called &mybinvar.