Computer Science Canada Highscore Library |
Author: | Aziz [ Thu Jun 09, 2005 7:26 am ] | ||
Post subject: | Highscore Library | ||
If that's what you'll call it? Anyways I've come up with a nifty module for using Highscores (any amount of names, scores, as well as using multiple files) I've attached the .tu file. Here's the syntax: fcn Size (fileName : string) : int Returns the size (how many scores & names) of the file fileName. ex. a file like this: Aziz$200# Marcus$75# Joel$30# has a size of 3 proc CreateFile (size : int, fileName : string) Creates a highscore file of size size with the file name fileName. All names will be defaulted to "---" and score will be defaulted to 0. proc ClearScores (fileName : string) Resets all the names in the file to "---" and scores to 0. proc GetScores (var names : array 1 .. * of string, var scores : array 1 .. * of int, fileName : string) Stores all the names and scores of the highscore file fileName into the names and scores parameters. proc AddScore (userName : string, userScore : int, fileName : string) Add a name and score to the highscore file fileName. fcn TopName (fileName : string) : string Returns the name of the top score holder. fcn TopScore (fileName : string) : int Returns the score of the top score holder. Also, here's a test program to try it out:
You can use this by putting "import "Highscore.tu"" in your file. All procedures and function are export qualified. File is attached |
Author: | decon1985 [ Thu Jun 09, 2005 12:51 pm ] |
Post subject: | AWSOMENESS! |
This is really useful! Man, i wouldn't change a thing! |
Author: | dann_west [ Fri Jun 10, 2005 2:25 pm ] |
Post subject: | Re: Highscore Library |
nice! From D |