import "Highscore.tu"
var fileName, choice : string
var size : int
loop
cls
put "Highscore file name [type ESC to exit]: " ..
get fileName : *
exit when Str.Upper (fileName) = "ESC"
if File.Exists (fileName) then
put "File Found."
else
put "File Not Found, define size of new file?", skip, "If no, default size to 10 scores [Y/N] " ..
loop
get choice : *
choice := Str.Upper (choice)
exit when choice = "Y" or choice = "N"
locate (whatrow - 1, 40)
end loop
if choice = "Y" then
put "# Of Highscores to be stored: " ..
get size
put "Number of highscores in ", fileName, " set to ", size, "."
else
put "Number of highscores in ", fileName, " defaulted to 10."
size := 10
end if
Highscore.CreateFile (size, fileName)
put "File ", fileName, " created."
end if
put skip, "Any key to continue"
Input.Pause
loop
var choice2, score : int
var name : string
var names : array 1 .. Highscore.Size (fileName) of string
var scores : array 1 .. Highscore.Size (fileName) of int
cls
put "Commands for highscore list ", fileName, ":"
put "1: Get List Size"
put "2: Clear the scores"
put "3: Display list of Highscores"
put "4: Check the top place holder"
put "5: Add a score"
put "6: Delete file"
put "7: Exit"
loop
get choice2
exit when choice2 >= 1 and choice2 <= 7
locate (whatrow - 1, 1)
end loop
cls
if choice2 = 1 then
put "The highscore list holds ", Highscore.Size (fileName), " scores."
elsif choice2 = 2 then
Highscore.ClearScores (fileName)
put "Scores Cleare :)"
elsif choice2 = 3 then
Highscore.GetScores (names, scores, fileName)
put "Name" : 10, "Score" : 5
for i : 1 .. Highscore.Size (fileName)
put names (i) : 10, scores (i) : 5
end for
elsif choice2 = 4 then
put "The top score holder is ", Highscore.TopName (fileName), " with a score of ", Highscore.TopScore (fileName), "."
elsif choice2 = 5 then
put "Name: " ..
get name : *
put "Score: " ..
get score
Highscore.AddScore (name, score, fileName)
put "Score added."
elsif choice2 = 6 then
File.Delete (fileName)
put "File deleted. Any key to return to finish."
Input.Pause
exit
else
exit
end if
put skip, "Any key to continue." ..
Input.Pause
end loop
end loop
Window.Hide (defWinID)
|