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

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
ConfusedAboutFiles
Newbie
Posts: 2
Joined: Mon Jan 21, 2008 9:57 am

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

Post 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?
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

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

Post 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
ConfusedAboutFiles
Newbie
Posts: 2
Joined: Mon Jan 21, 2008 9:57 am

Post 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.
Post Reply