/* Mode=Run */ /* *********************************************************************** REFEREES PROGRAM FOR FOOTBALL REXX SUITE ------------------------------------------ Copyright Mark Naughton 1999 Version Date History -------------------------------------------------------------------------- 1.0 170699 First release. 250899 Added error msg to file check. 280899 Converted to use locale. Some error messages, before reading the locale, will still be in English. 281199 Added support for number of cards shown and the average number of cards per match. ************************************************************************** Procedure --------- 1. Check file exists. 2. Open '.sflearn' file and read in referees, storing them and if the name appears more than once, increment the number of matches played. 3. Write referees out to temp file and sort. 4. Display table. 5. Read temp file and display referees with total matches. Exit. ************************************************************************** */ PARSE ARG league_stuff version = 1 input_file = '.sflearn' refs = '*RF=' rfnm = '**' separator = '*' teams. = '???' wins. = '???' games. = '???' rcards. = '???' ycards. = '???' counter = 0 league_file = "Data/" || league_stuff if open(datafile,"Data/Football.locale",'r') then do line = readln(datafile) locdir = strip(line) close(datafile) end else do say say "ERROR : (Referees)" say say "Cannot read 'Data/Football.locale' for the locale settings." exit end locdir = locdir"User/Referees.data" if open(datafile,"ENV:FootballRXPath",'r') then do line = readln(datafile) rxdir = strip(line) close(datafile) end else rxdir = "SYS:Rexxc/" if exists(locdir) > 0 then do address command rxdir'rx 'locdir VarCount = getclip('VarCount') do i = 1 to VarCount interpret getclip('var.'i) end end else do say say "ERROR : (Referees)" say say "Cannot find '"locdir"' to read locale settings." exit end if exists(league_file || input_file) = 0 then do say say rf_error say say rf_one"'"league_file || input_file"'." exit end if open(datafile,league_file || input_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos(rfnm,line) > 0 then lname = delstr(line,1,3) if pos(separator,line) = 0 then notin = -1 if pos(refs,line) > 0 then do name = delstr(line,1,4) notin = 0 do i=1 to counter if pos(name,teams.i) > 0 then do games.i = games.i + 1 mkr = i notin = 1 end end if notin = 0 then do counter = counter + 1 teams.counter = name games.counter = 1 ycards.counter = 0 rcards.counter = 0 mkr = counter end end if notin > -1 & mkr > 0 then do if pos("*HR=",line) > 0 then rcards.mkr = rcards.mkr + 1 if pos("*AR=",line) > 0 then rcards.mkr = rcards.mkr + 1 if pos("*HY=",line) > 0 then ycards.mkr = ycards.mkr + 1 if pos("*AY=",line) > 0 then ycards.mkr = ycards.mkr + 1 if pos("*HYR=",line) > 0 then do ycards.mkr = ycards.mkr + 1 rcards.mkr = rcards.mkr + 1 end if pos("*AYR=",line) > 0 then do ycards.mkr = ycards.mkr + 1 rcards.mkr = rcards.mkr + 1 end end end close(datafile) end else do say say rf_error say say rf_two"'"league_file||input_file"'"rf_three exit end if counter > 1 then do if open(datafile,"RAM:Football.tempcup",'w') then do do i=1 to counter wins.i = trunc((ycards.i+rcards.i)/games.i,2) writeln(datafile,left(wins.i,5)" "left(teams.i,35,' ')" "left(games.i,5)" "left(ycards.i,6)" "rcards.i) end close(datafile) end else do say say rf_error say say rf_four exit end address command 'Exec/Sort5Chars ' end gt = 0 yt = 0 rt = 0 do i=1 to counter gt = gt + games.i yt = yt + ycards.i rt = rt + rcards.i end say say center(rf_txt1"'"lname"'",78) say "-------------------------------------------------------------------------------" say say say rf_txt2 say "-------------------------------------------------------------------------------" say i = 0 if counter = 1 then do say left(teams.1,35,' ')" "left(games.i,5)" "left(ycards.i,6)" "left(rcards.i,4)" "wins.1 say end else do if open(datafile,"RAM:Football.tempcup",'r') then do do while ~eof(datafile) line = readln(datafile) if line ~= "" then do rating = word(line,1) aline = left(strip(substr(line,5)),55,' ')" "rating if i = 0 then do say upper(aline) i = 1 end else say aline end end close(datafile) end else do say say rf_error say say rf_txt3 exit end address command 'delete >NIL: RAM:Football.tempcup' end say "-------------------------------------------------------------------------------" say rf_txt4" "left(gt,5)" "left(yt,6)" "rt say "-------------------------------------------------------------------------------" exit