Small Basic creates text based files – there is no explicit capability to store columns of values. To overcome this there are a number of options available:
My first option is to store each value on a new line so that for our ‘name’ and ‘score’ value sets, two lines would be used.
Advantage: I can easily see (using Notepad), each pair of values on two adjacent lines in the file.
Disadvantage: I would need to remember that each player would take two lines and I would need to read lines as pairs.
A second option would be to place all the names sequentially and then follow this with the scores for each player.
Advantage: I can read the first 10 lines – players’ names, and then use an offset value of 10 to read that players score.
Disadvantage: Initially there will not be 10 payers in the file so I would need to be careful to make sure we read the correct score for each player.
Another solution would be to use two files – one for the names and one for the high scores
Advantage: Each file would have a maximum of ten lines and each line in each file would be the data for a specific player / score.
Disadvantage: I would be dealing with two files and if one became corrupted, the whole system would be incorrect or unusable.
Finally I could construct each line to have a CSV structure using a comma or other special character to separate the values.
Advantage: Each line contains all the data needed for an individual record so there could be no confusion.
Disadvantage: I will need to make my program manage all aspects of the structure myself as there is no CSV structure in Small Basic.