Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / read file how many lines are written?

Author
Message
Jo Bach
9
Years of Service
User Offline
Joined: 22nd Dec 2014
Location:
Posted: 11th Oct 2015 20:34
Hi,

I want to write a score each day someone plays the game. Like "date and score".

When reading the file to make a chart of the year-score, I need te know how many lines are written to the file, becouse someone is not playing it every day.

Question 1:
Can I write a string at the end of a saved file, or will the first written lines be deleted?

Question 2:
I can't use Repeat, ReadString() etc becouse I don't know how many lines are written, is there a way to read this out?

Maybe there is a simple solution, but I can't find it (same problem as readding the GetStringToken() I think).

Thanks.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Oct 2015 20:56
Use WriteLine() and ReadLine() to write/read each line

While Not FileEOF() will keep reading until the end of the file. Then you don't need to know how may lines there are.

OpenToWrite() has a second parameter that allows you to append to the end of an existing file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Jo Bach
9
Years of Service
User Offline
Joined: 22nd Dec 2014
Location:
Posted: 16th Dec 2015 21:26
Took a while for me to answer becouse this new forum has nog automatic mailing on reactions?

So thank you very much for your help, EOF stands for 'end of file' I suppose



GunnerJnr
AGK Developer
8
Years of Service
User Offline
Joined: 30th Nov 2015
Location: Bridgwater, UK
Posted: 21st Dec 2015 09:52 Edited at: 21st Dec 2015 13:42
Not sure if this is any use to you but I wrote it to help me with debugging purposes and its useful for printing to a debuglog.txt file, it also appends the document (which automatically adds the new stuff under the old stuff)

Constants.agc



Globals.agc



Debuglog.agc



main.agc usage



Image of it in action




Anyway its possibly not what you wanted to know but might prove handy for anybody in the future

Cheers
GunnerJnr

Login to post a reply

Server time is: 2024-11-21 15:16:30
Your offset time is: 2024-11-21 15:16:30