Page 1 of 1

Maybe I'm just not looking hard enough...

Posted: Mon Jan 21, 2008 10:12 am
by ConfusedAboutFiles
I've just finished a course in Qbasic at school, and we worked with external files. Now you can use external files to keep track of a person's score right, but what if you had multiple people and wanted them to all be included one the scoreboard and external file. Say I had this

"Player1",500
"Player2",300
"Player3",600


Alright, now since I got that, and Player2 decides to play again, how can I edit that specific record from QBasic without messing up the file? Or can you just not do it?

Re: Maybe I'm just not looking hard enough...

Posted: Mon Jan 21, 2008 3:56 pm
by Mac
ConfusedAboutFiles wrote:how can I edit that specific record from QBasic without messing up the file
Typically, you rewrite the file.

1) Read the file into arrays in your program. Now you don't need the file any more.

2) Update any "records" you please by changing array values.

3) Re-create the file by writing all the info in the arrays.

Mac

Posted: Tue Jan 22, 2008 4:50 pm
by ConfusedAboutFiles
Thank you, it worked perfectly, I didn't think you could re-write the whole entire file with the same data :)

Thank you, sir.