Sub MovingAVG()
Dim sampleSize As Int, maDuration As Int
sampleSize=500
Dim sampleData(samplesize) As Byte
maDuration=30
For k=0 To sampleSize-1
sampleData(k)=Rnd(0,256)
Next
Dim ma As List
ma.Initialize
Dim theAVG As Int
For x = 0 To sampleData.Length - 1
ma.InsertAt(0, sampleData(x))
theAVG = 0
For y = 0 To ma.Size - 1
theAVG = theAVG+ma.Get(y)
Next
theAVG = theAVG / ma.Size
Log("theAVG " & theAVG)
If ma.size = maDuration Then
ma.RemoveAt(ma.size - 1)
End If
Next
End Sub