我有一个用于排行榜的系统,要求您输入姓名,并将您的分数保存到文本文件中。当按下得分按钮时,此文本文件将再次打开,显示所有高分。 现在,当按下得分按钮时,它只会在空白窗口中回答。 文件Scores.txt确实保存了所有分数。 这是分数按钮的文字:
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
这是将分数保存到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
答案 0 :(得分:0)
在stopGame中,您错过了斜杠“ /”,它应该与mouseUp中的斜杠相同:
put specialFolderPath("Documents") & "/Scores.txt" into myFile
祝你好运!