$fread

From Scriptwiki
Revision as of 17:58, 19 December 2005 by Doomie (talk | contribs) (Mhh)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.