FileCurrentPos

FileCurrentPos
int FileCurrentPos(int file)

Documentation

Pass a file handle opened in either read or write mode, and it returns the number of preceding bytes to the current position. As all read/write functions automatically increment the position, this is will generally return the number of the next byte to be read/written.

Example Usage

int file = FileOpen("dump.dat", FILE_WRITE);
Log("Start: "+str(FileCurrentPos(file)));
FileWriteQuad(file, 97);
Log("After Quad: "+str(FileCurrentPos(file)));
FileWriteString(file, "Four");
Log("After String: "+str(FileCurrentPos(file)));
FileClose(file);
// Creates/overwrites a new file and writes some data
// Logging the position after each step, like so:
// "Start: 0"
// "After Quad: 4"
// "After String: 10"
// Position starts at 0
// After writing a quad byte position is 4
// After writing a string of length 4, with 2 byte header
// Incrememnts another 6, for a total position of 10
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.