string FileReadString(int file)
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.
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
There are no talkbacks on this documentation page yet. Post the first?
Doc Nav |
Your docs |