Posted: Sun Jun 19, 2011 11:49 pm Post subject: RE:Making Monsters in a game?
i want it to make a list of the top 10 scores.
this is what i tried, it would overite the old one each time. I want to make a list of top 10 players.
This is for my final culminating project that is due tomorrow. Please help! Thanks
for i : 1 .. 1
open : stream, "myText.txt", get
get : stream, name (i)
open : stream, "myText.txt", put
cls
put "What is your name"
View.Update
get name (i) : *
View.Update
put : stream, name (i), " " : 10, minutes, ":", seconds, ".", milliseconds
put "Your score will be saved!"
put name (i), " ", minutes, ":", seconds, ".", milliseconds
View.Update
close : stream
end for
Tony
Posted: Mon Jun 20, 2011 1:34 am Post subject: RE:Making Monsters in a game?
Nothing in that code suggests that 10 players are involved.
- you need to remember that writing to a file starts from the top, and will over-write previous content.
- "top 10" suggests that scores need to be sorted, to figure out which ones are in that list.
Posted: Mon Jun 20, 2011 7:40 am Post subject: RE:Making Monsters in a game?
how will I be able to add code with out overwriting? I tried retrieving the file first so it has the current info and then writing it but it still overites the old text.
Tony
Posted: Mon Jun 20, 2011 10:02 am Post subject: RE:Making Monsters in a game?
You are opening a new stream for writing _after_ reading, so that starts at the start again. Besides, this wound't works with variable-sized lines.
Overwriting the entire file is the easiest thing to do.