REM this program takes a multiple-warrior report produced
REM by TESTALL.BAT etc and extracts score ratio information
REM outputs file with a line for each warrior in the report
REM containing warrior name, bench score, points ratio, wins
REM points ration = sum of warrior points / sum of bench points
LINE INPUT "TESTALL report file: "; testfile$
testfile$ = LTRIM$(RTRIM$(testfile$)): IF testfile$ = "" THEN SYSTEM
LINE INPUT "Output score ratio file: "; outfile$
outfile$ = LTRIM$(RTRIM$(outfile$)): IF outfile$ = "" THEN SYSTEM
ON ERROR GOTO nofile
GOTO start
nofile:
CLOSE : PRINT "Error": SYSTEM
start:
OPEN testfile$ FOR INPUT AS #1
OPEN outfile$ FOR OUTPUT AS #2
inchart = 0  'indicates when in a warrior performance chart
WHILE NOT EOF(1)
 LINE INPUT #1, a$
 IF LEFT$(a$, 34) = "Opponent        Scores    Results " THEN
  warrior$ = LEFT$(MID$(a$ + "                    ", 54), 20)
 END IF
 IF LEFT$(a$, 48) = "--------------- --------- ----------- ---------=" THEN
  IF inchart = 0 THEN
   inchart = 1: warriortotal = 0: opponenttotal = 0: nwars = 0: nwins = 0
  ELSE
   inchart = 0
  END IF
 ELSE
  IF inchart THEN
   warriorscore = VAL(MID$(a$, 17, 4))
   opponentscore = VAL(MID$(a$, 22, 4))
   warriortotal = warriortotal + warriorscore
   opponenttotal = opponenttotal + opponentscore
   nwars = nwars + 1
   IF warriorscore > opponentscore THEN nwins = nwins + 1
  END IF
 END IF
 IF LEFT$(a$, 16) = "Adjusted Score: " THEN
  warriorscore$ = "  " + LEFT$(MID$(a$, 17) + "    ", 7)
  IF opponenttotal > 0 THEN
   scoreratio = warriortotal / opponenttotal
   ratio$ = LEFT$(STR$(scoreratio) + "          ", 10)
  ELSE
   ratio$ = " Infinite "
  END IF
  PRINT #2, warrior$; warriorscore$; ratio$;
  PRINT #2, "  Won"; nwins; "out of"; nwars; "battles"
 END IF
WEND
CLOSE
SYSTEM

