Re: read gamelog from scripts.dll [message #205917 is a reply to message #205903] |
Wed, 28 June 2006 16:54   |
 |
theplague
Messages: 261 Registered: May 2004
Karma:
|
Recruit |
|
|
well, heres a clue, you gotta do it line, by line. As in, everytime you read it, you gotta load the whole file, then set the position you wanna read from.
long last_line = 0;
ifstream gamelog("example_gamelog_name.txt"); // gamelog names do change, your gonna have to generate the correct names
if (gamelog.is_open()) {
std::string line;
gamelog.seekg (last_line, ios::beg); // puts it back to the last read position
while (!gamelog.eof()) { // reads until the end of file is reached
getline(gamelog,line); // saves a line into a string 'line' to do with as you wish
}
gamelog.seekg(0, ios::end); // sets the pointer to the last point in the file
last_line = gamelog.tellg(); // saves the last point into the variable 'last_line'
} else {
printf("Error occured, gamelog unreadable.\n");
}
and all this could be within a function and called every X time period, or whenever checking of new lines is needed.

[Updated on: Wed, 28 June 2006 16:55] Report message to a moderator
|
|
|