61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
Dim As String filename = "readings.txt"
|
|
Dim As String linea, Part, salida, ErrEnds, rejected_date, Tabu = Chr(9)
|
|
Dim As Integer i, posic, startPos, endPos, Errcnt, ErrMax, rejects,
|
|
Dim As Integer readings, max_rejected, n_rejected
|
|
Dim As Double lsum, tsum, valor
|
|
|
|
Open filename For Input As #1
|
|
|
|
Do While Not Eof(1)
|
|
Line Input #1, linea
|
|
salida = ""
|
|
lsum = 0
|
|
rejects = 0
|
|
posic = 1
|
|
For i = 1 To 1 + 2 * 24
|
|
startPos = posic
|
|
endPos = Instr(posic, linea, Tabu)
|
|
If endPos = 0 Then endPos = Len(linea) + 1
|
|
Part = Mid(linea, startPos, endPos - startPos)
|
|
posic = endPos + 1
|
|
|
|
If i = 1 Then ' Date
|
|
salida = Part
|
|
Elseif i Mod 2 = 0 Then ' Recorded value
|
|
valor = Val(Part)
|
|
Else ' Status part
|
|
If Val(Part) > 0 Then
|
|
Errcnt = 0
|
|
readings += 1
|
|
lsum += valor
|
|
tsum += valor
|
|
Else
|
|
rejects += 1
|
|
Errcnt += 1
|
|
If Errcnt > ErrMax Then
|
|
ErrMax = Errcnt
|
|
ErrEnds = salida
|
|
End If
|
|
End If
|
|
End If
|
|
Next i
|
|
salida &= " Rejects: " & Str(rejects)
|
|
salida &= " Accepts: " & Str(24 - rejects)
|
|
salida &= " Line_tot: " & Str(lsum)
|
|
If rejects < 24 Then
|
|
salida &= " Line_avg: " & Str(lsum / (24 - rejects))
|
|
Else
|
|
salida &= " Line_avg: N/A"
|
|
End If
|
|
Print "Line: " & salida
|
|
Loop
|
|
Close #1
|
|
|
|
Print !"\nFile = " & filename
|
|
Print "Total = " & Str(tsum)
|
|
Print "Readings = " & Str(readings)
|
|
Print "Average = " & Str(tsum / readings)
|
|
Print !"\nMaximum of " & Str(ErrMax) & " consecutive false readings, ends at " & ErrEnds
|
|
|
|
Sleep
|