You must be logged in to do that.

FileReadString

FileReadString
string FileReadString(int file)

Documentation

Pass a handle to a file open in read mode, and it returns a string of bytes in ascii, of length determined by a two byte header. The file reads from the current position, and increments the position to the end of the string. Note the string to be read must have been written using FileWriteString() as it needs the two byte header to know how much of the file to read.

Example Usage

string text = "Check me";
int file = FileOpen("test.txt", FILE_WRITE);
FileWriteString(file, text);
FileClose(file);
int file = FileOpen("test.txt", FILE_READ);
if (strcmp(FileReadString(file), text)) Log("LIES!");
else Log("Truth!");
FileClose(file);
// So, that should should always log the truth
// Don't let strcmp confuse you there, it's always
// The wrong way around, returns 0 on match


int file = FileOpen("readme.txt", FILE_READ);
Log(str(len(FileReadString(file))));
FileClose(file);
// This logs a length of 9318 for the string read
// As it wrongly interpreted the first two bytes
// As a length in word format. Make sure to only
// Use this when the data was written correctly
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.