# Lots of questions...

• ### Question

• Say i had to store someones score for a quiz, i store it in a simple variable. but if i needed to store the past three scores ONLY and then store them in an external file how would i go about doing that??
Thursday, January 29, 2015 6:17 PM

• Here ya go! This figures it out for you with a random score and displays it:

```While 1 = 1
Program.Delay(1000)
On_Score()
TextWindow.Clear()
For i = 3 To 1 Step -1
TextWindow.WriteLine(Score_Array[i])
EndFor
EndWhile

Sub On_score
Score = Math.GetRandomNumber(100)
Prev_Score_Array = Score_Array

Score_Array[3] = Prev_Score_Array[2]
Score_Array[2] = Prev_Score_Array[1]
Score_Array[1] = Score
EndSub```

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

• Proposed as answer by Thursday, January 29, 2015 8:45 PM
• Marked as answer by Friday, January 30, 2015 7:27 PM
Thursday, January 29, 2015 8:22 PM

### All replies

• Here ya go! This figures it out for you with a random score and displays it:

```While 1 = 1
Program.Delay(1000)
On_Score()
TextWindow.Clear()
For i = 3 To 1 Step -1
TextWindow.WriteLine(Score_Array[i])
EndFor
EndWhile

Sub On_score
Score = Math.GetRandomNumber(100)
Prev_Score_Array = Score_Array

Score_Array[3] = Prev_Score_Array[2]
Score_Array[2] = Prev_Score_Array[1]
Score_Array[1] = Score
EndSub```

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

• Proposed as answer by Thursday, January 29, 2015 8:45 PM
• Marked as answer by Friday, January 30, 2015 7:27 PM
Thursday, January 29, 2015 8:22 PM
• This works ok but you don't really need the second array

```  Score_Array[3] = Score_Array[2]
Score_Array[2] = Score_Array[1]
Score_Array[1] = Score```

would be fine.

Also, to make a more general solution that would cope with any number of scores (not just three) you could use a loop in the subroutine. First you need to get the length of the array then...

`For i = lengthOfArray to 2 Step -1	Score_Array[i] = Score_Array[i-1]NextScore_Array[1] = Score`

If I remember correctly, you get the length of the array like this

lengthOfArray = Array.GetItemCount(Score_Array)

Friday, January 30, 2015 7:35 AM
• I was trying to make it simple for him. :D

It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

Friday, January 30, 2015 5:32 PM
• Cheers guys you really helped me out

Friday, January 30, 2015 7:28 PM