Prev | Current Page 598 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

You can use a positive number
if you want the marker to move forward, or negative to move backward. The second parameter is a
neko.io.File.FileSeek enumerator, which contains three possible values:
SeekCur
SeekBegin
SeekEnd
SeekCur maps the bytes the marker should move from its current location in the stream. SeekBegin
maps from the beginning of the stream, while SeekEnd maps from the end. For example, the following
class writes a string containing the first ten letters in the alphabet:
import neko.io.File;
class Seek
{
public static function main()
{
var stream = neko.io.File.write( ???example.txt???, false );
var str = ???abcdefghijklmnopqrstuvwxyz???;
try
{
stream.writeBytes( str, 0, 10 );
stream.seek( 3, SeekEnd );
stream.writeBytes( str, 0, 10 );
stream.seek( 3, SeekBegin );
stream.writeBytes( str, 0, 10 );
stream.seek( -5, SeekCur );
stream.writeBytes( str, 0, 3 );
}
catch ( err : Dynamic)
{
//neko.Lib.print( err );
}
stream.close();
}
}
If you run the code, you should receive an output example.


Pages:
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610