Fill blank spaces in an array

Hey,

If you have a 1D array that you are populating and writing to a text file is there a way to fill in blank spaces automatically? This is part of a highscore table I am trying to create but when someone is added to the table the lowest member is overwritten and the whole table is resorted, But when resorting the table the names are lost and replaced with blanks that cant be read in.

This is the code

SUB AddToHighScore(UsersName$, Winnings, HighScoreNames$(), HighScoreNumbers())
REM A subrotuine that will decide if the user has won enough to get on the highscore table and add them if needed
OPEN #3: name "Names.txt", CREATE newold, org text, access outin
OPEN #4: name "Winnings.txt", CREATE newold, org text, access outin
FOR ReadingLoop = 1 TO 1
INPUT #3: HighScoreNames$(ReadingLoop)
INPUT #4: HighScoreNumbers(ReadingLoop)
NEXT ReadingLoop
CLOSE #3
CLOSE #4
UNSAVE "Names.txt"
UNSAVE "Winnings.txt"
IF Winnings > HighScoreNumbers(10) THEN
PRINT "You have won enough money to get on the high score table!"
LET HighScoreNames$(10) = UsersName$
LET HighScoreNumbers(10) = Winnings
END IF
REM This sorting algrothim is to sort the high score table while keeping the names in the correct posions to the money won
LET ListSorted$ = "False"
LET ListSize = 10
DO while(ListSize > 0) AND (ListSorted$ = "False")
LET ListSorted$ = "True"
FOR Element = 1 TO ListSize -1
IF HighScoreNumbers(Element) > HighScoreNumbers(Element + 1) THEN
LET SwapValueMoney = HighScoreNumbers(Element)
LET SwapValueName$ = HighScoreNames$(Element)
LET HighScoreNumbers(Element) = HighScoreNumbers(Element + 1)
LET HighScoreNames$(Element) = HighScoreNames$(Element + 1)
LET HighScoreNumbers(Element + 1) = SwapValueMoney
LET HighScoreNames$(Element + 1) = SwapValueName$
LET ListSorted$ = "False"
END IF
NEXT Element
LET ListSize = ListSize - 1
LOOP
OPEN #3: name "Names.txt", CREATE newold, org text, access outin
OPEN #4: name "Winnings.txt", CREATE newold, org text, access outin
FOR WriteCounter = 1 to 10
PRINT #3: HighScoreNames$(WriteCounter)
PRINT #4: HighScoreNumbers(WriteCounter)
NEXT WriteCounter
CLOSE #3
CLOSE #4
END SUB

Thanks

Comments

Re: Fill blank spaces in an array ...

BryceN... To solve your problem, the simplest fix is to create a second 1D array; let's name it scratch$(0). Then, when ever you need to modify your main 1D text array, with assumed name main$(n), you write the program line:

MAT scratch$ = main$

Now you can do whatever you need to do using scratch$. When finished, you write program line:

MAT main$ = scratch$

Looks easy. Regards ... Tom M