Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/Text-processing-1/BBC-BASIC/text-processing-1.basic
Normal file
43
Task/Text-processing-1/BBC-BASIC/text-processing-1.basic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
file% = OPENIN("readings.txt")
|
||||
IF file% = 0 THEN PRINT "Could not open test data file" : END
|
||||
|
||||
Total = 0
|
||||
Count% = 0
|
||||
BadMax% = 0
|
||||
bad% = 0
|
||||
WHILE NOT EOF#file%
|
||||
text$ = GET$#file%
|
||||
IF text$<>"" THEN
|
||||
tab% = INSTR(text$, CHR$(9))
|
||||
date$ = LEFT$(text$, tab% - 1)
|
||||
acc = 0
|
||||
cnt% = 0
|
||||
FOR field% = 1 TO 24
|
||||
dval = VALMID$(text$, tab%+1)
|
||||
tab% = INSTR(text$, CHR$(9), tab%+1)
|
||||
flag% = VALMID$(text$, tab%+1)
|
||||
tab% = INSTR(text$, CHR$(9), tab%+1)
|
||||
IF flag% > 0 THEN
|
||||
acc += dval
|
||||
cnt% += 1
|
||||
bad% = 0
|
||||
ELSE
|
||||
bad% += 1
|
||||
IF bad% > BadMax% BadMax% = bad% : BadDate$ = date$
|
||||
ENDIF
|
||||
NEXT field%
|
||||
@% = &90A
|
||||
PRINT "Date: " date$ " Good = "; cnt%, " Bad = "; 24-cnt%, ;
|
||||
@% = &20308
|
||||
IF cnt% THEN PRINT " Total = " acc " Mean = " acc / cnt% ;
|
||||
PRINT
|
||||
Total += acc
|
||||
Count% += cnt%
|
||||
ENDIF
|
||||
ENDWHILE
|
||||
CLOSE #file%
|
||||
PRINT ' "Grand total = " ; Total
|
||||
PRINT "Number of valid readings = " ; STR$(Count%)
|
||||
PRINT "Overall mean = " ; Total / Count%
|
||||
@% = &90A
|
||||
PRINT '"Longest run of bad readings = " ; BadMax% " ending " BadDate$
|
||||
Loading…
Add table
Add a link
Reference in a new issue