Reputation: 181
I have a system for a highscore, which asks you to enter your name, and it will save your score into a text file. This text file will then be opened again when the score button is pressed, showing all the high scores. Right now, when the score button is pressed, it only answers with a blank window. The file Scores.txt does have the scores all saved. Here is the text for the scores button:
on mouseUp
put specialFolderPath("documents") & "/Scores.txt" into myFile
set itemDelimiter to tab
put url ("file:" & myFile) into x
sort lines of x numeric descending by item 2 of each
answer x
end mouseUp
Here is the code which saves the scores to scores.txt:
on stopGame
put false into gameisRunning
set the bottom of btn "bird" to 225
set the angle of image "Bird" of stack "graphics" to 0
ask "What is your name?"
if it is not empty then
put it into theName
put specialFolderPath("Documents") & "Scores.txt" into myFile
put URL("file:" & myFile) into highScores
put theName & tab & field "score" & return after highScores
put highScores into URL ( "File:" & myFile)
end if
end stopGame
Upvotes: 0
Views: 108
Reputation: 436
In the stopGame you have missed the slash "/" it should be the same as you had in the mouseUp:
put specialFolderPath("Documents") & "/Scores.txt" into myFile
Good Luck!
Upvotes: 1