/* *********************************************************************** CUP INFORMATION PROGRAM FOR FOOTBALL REXX SUITE ------------------------------------------------- Copyright Mark Naughton 1998 Version Date History -------------------------------------------------------------------------- 1.0 140998 First release. 160998 Changed way best record is calculated. ************************************************************************** Procedure --------- 1. Check files exist. 2. Read '.cf' file and get details. Read '.cfrw' and do the same. 3. If '.cfsave' doesn't exist, read the '.scf' file adjusting the output for replays, extra time, first leg and penalties. 4. If '.cfsave' is found, read to display current matches. 5. Read '.scf' into an array. Search array, storing goals. When finished, search through the team array, calculating the best record : (Goals Scored / Goals Away) * Matches Played Goals Scored = Goals Scored At Home + (Goals Scored Away * 1.5) 6. Write data to a file and call an external sort program. Read the details back in and delete the temporary file. 7. Adjust options. 8. Display report : display options/rounds, teams and the best record, the current round matches and if the history file has been selected, read the file for previous/current winners. 9. Exit. ************************************************************************** */ PARSE ARG league_stuff version = 1 input_file = '.cf' input2_file = '.scf' input3_file = '.cfrw' input4_file = '.cfh' input5_file = '.cfsave' output_file = 'RAM:Football.tempcup' title = '*CUP_TITLE=' thirdpl = '*CUP_THIRD=' rounddef = '*CUP_RNDDEF=' currond = '*CUP_ROND=' currrondn = '*CUP_CRDN=' roundddef = '*CUP_RDEF=' cuphistory = '*CUP_HISTORY=' thirdpl = '*CUP_THIRD=' teams_cnt = '*CUP_TCNT=' awaygs = '*CUP_AWAYG=' schedtype = '*CUP_SCHEDULE=' first = '*WINNER=' pkversion = '* Version=' matches. = '???' separator = '*' teams. = '???' rnds. = '???' lines. = '???' replays. = '???' working. = '???' losing. = '???' repct = 0 repno. = '???' tcount = 0 ttc = 0 rndcnt = 0 linesct = 0 league_file = "Data/"league_stuff curnd = '' curndn = 0 not_played = "__ __" mcount = 0 bstats. = '???' btemp. = '???' btcnt = 0 bpstats. = '???' bgsstats. = '???' bgastats. = '???' bagstats. = '???' parse var league_stuff league_file search_team league_file = "Data/" || league_file if exists(league_file || input_file) = 0 then exit if exists(league_file || input2_file) = 0 then exit tcount = 0 if open(datafile,league_file || input_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos(title,line) > 0 then cupname = delstr(line,1,11) if pos(thirdpl,line) > 0 then third = delstr(line,1,11) if pos(awaygs,line) > 0 then awaygoals= delstr(line,1,11) if pos(pkversion,line) > 0 then fversion = delstr(line,1,12) if pos(cuphistory,line) > 0 then cuph = delstr(line,1,13) if pos(schedtype,line) > 0 then scht = delstr(line,1,14) if pos(rounddef,line) > 0 then do rndcnt = rndcnt + 1 rnds.rndcnt = delstr(line,1,12) end if pos(separator,line) = 0 then do line = strip(line) tcount = tcount + 1 teams.tcount = line end end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Unable to open '"league_file || input_file"' file." exit end if open(datafile,league_file || input3_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos(currond,line) > 0 then crond = strip(substr(line,11,2)) if pos(roundddef,line) > 0 then tcrondn= strip(substr(line,11,5)) if pos(currrondn,line) > 0 then do crondn = strip(substr(line,11,30)) tleg_no = 0 if pos("1 Leg",line) > 0 then tleg_no = 1 if pos("2 Legs",line) > 0 then tleg_no = 2 end end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Unable to open '"league_file || input3_file"' file." exit end a = 0 mcount = 0 if exists(league_file || input5_file) = 0 then do if open(datafile,league_file || input2_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos("*Round="strip(tcrondn),line) > 0 then a = 1 if a = 1 then do if pos(separator,line) = 0 & pos('#',line) = 0 then do mcount = mcount + 1 matches.mcount = line end else do if pos("Replay",line) > 0 then do mcount = mcount + 1 matches.mcount = " " mcount = mcount + 1 matches.mcount = "Replay" mcount = mcount + 1 matches.mcount = "------" mcount = mcount + 1 matches.mcount = " " end if pos("#1st Leg",line) > 0 then do mcount = mcount + 1 matches.mcount = overlay("After 1st Leg",line,1,13) end if pos("#Score After Extra Time",line) > 0 then do mcount = mcount + 1 matches.mcount = overlay("Score After Extra Time ",line,1,23) end if pos("#Penalties",line) > 0 then do mcount = mcount + 1 matches.mcount = overlay("After Penalties",line,1,15) end end end end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Cannot open '"league_file||input2_file"' for reading." exit end end else do if open(datafile,league_file || input5_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos(separator,line) = 0 & pos('#',line) = 0 then do mcount = mcount + 1 matches.mcount = line end else do if pos(not_played,line) = 0 then do if pos("Replay",line) > 0 then do mcount = mcount + 1 matches.mcount = " " mcount = mcount + 1 matches.mcount = "Replay" mcount = mcount + 1 matches.mcount = "------" mcount = mcount + 1 matches.mcount = " " end if pos("#1st Leg",line) > 0 then do mcount = mcount + 1 matches.mcount = line matches.mcount = overlay("After 1st Leg",matches.mcount,1,13) end if pos("#Score After Extra Time",line) > 0 then do mcount = mcount + 1 matches.mcount = line matches.mcount = overlay("Score After Extra Time ",matches.mcount,1,23) end if pos("#Penalties",line) > 0 then do mcount = mcount + 1 matches.mcount = line matches.mcount = overlay("After Penalties",matches.mcount,1,15) end end end end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Cannot open '"league_file||input5_file"' for reading." exit end end do i=1 to tcount bpstats.i = 0 bgsstats.i = 0 bgastats.i = 0 bagstats.i = 0 end np = 0 btcnt = 0 if open(datafile,league_file || input2_file,'r') then do do while ~eof(datafile) line = readln(datafile) btcnt = btcnt + 1 btemp.btcnt = line end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Cannot open '"league_file||input2_file"' for reading." exit end do k=1 to btcnt if pos(not_played,btemp.k) = 0 & pos(separator,btemp.k) = 0 & pos('#',btemp.k) = 0 then do teama = strip(substr(btemp.k,1,30)) teamb = strip(substr(btemp.k,41,30)) np = 1 do l=1 to tcount if pos(teama,teams.l) > 0 then do bpstats.l = bpstats.l + 1 l11 = k + 1 if pos("#1st Leg",btemp.l11) > 0 then l11 = k + 2 if pos("Extra Time",btemp.l11) = 0 then do bgsstats.l = bgsstats.l + strip(substr(btemp.k,32,2)) bgastats.l = bgastats.l + strip(substr(btemp.k,37,2)) end else do bgsstats.l = bgsstats.l + strip(substr(btemp.l11,32,2)) bgastats.l = bgastats.l + strip(substr(btemp.l11,37,2)) end end if pos(teamb,teams.l) > 0 then do bpstats.l = bpstats.l + 1 l11 = k + 1 if pos("#1st Leg",btemp.l11) > 0 then l11 = k + 2 if pos("Extra Time",btemp.l11) = 0 then do bagstats.l = bagstats.l + strip(substr(btemp.k,37,2)) bgastats.l = bgastats.l + strip(substr(btemp.k,32,2)) end else do bagstats.l = bagstats.l + strip(substr(btemp.l11,37,2)) bgastats.l = bgastats.l + strip(substr(btemp.l11,32,2)) end end end end end if open(datafile,output_file,'w') then do do i=1 to tcount if bpstats.i = "" | bgsstats.i = "" | bgastats.i = "" | bagstats.i = "" then iterate if bgastats.i = 0 then /* average = "0.000" */ average = trunc((bgsstats.i + (bagstats.i * 1.5))*bpstats.i,3) else average = trunc(((bgsstats.i + (bagstats.i * 1.5))/bgastats.i)*bpstats.i,3) bstats.i = right(average,7)" "left(teams.i,30,' ')" "left(bpstats.i,3,' ')" "left(bgsstats.i+bagstats.i,3,' ')" "left(bgastats.i,3,' ') writeln(datafile,bstats.i) end close(datafile) address command 'Exec/Sort7Chars' btcnt = 0 if open(datafile,output_file,'r') then do do while ~eof(datafile) line = readln(datafile) if line ~= "" then do btcnt = btcnt + 1 bstats.btcnt = substr(line,9)" "substr(line,1,8) end end close(datafile) address command 'c:delete >NIL: 'output_file end else do say say "ERROR : (CupInformation)" say say "Unable to open '"output_file"' file for reading." exit end end else do say say "ERROR : (CupInformation)" say say "Unable to open '"output_file"' file for writing." exit end if pos("YES",cuph) > 0 then cuph = "Yes" else cuph = "No " if pos("YES",third) > 0 then third = "Yes" else third = "No " if pos("YES",awaygoals) > 0 then awaygoals = "Yes" else awaygoals = "No " say say center("Information for '"cupname"'",78) say "-------------------------------------------------------------------------------" say say "Away Goals : "awaygoals" (Only for Two-Leg matches)" say "Cup History : "cuph if pos("MANUAL",scht) > 0 then say "Scheduling : Manual" else say "Scheduling : Automatic" say "Third Place Play-Off : "third say say "This cup is scheduled for "rndcnt" rounds, with the following settings" say "regarding Extra Time and Penalties and Legs for each round as listed below..." say say "Round ExtraTime Penalties Legs" say "--------------------------------------------------" say do i=1 to rndcnt if pos("1 Leg",rnds.i) > 0 then do k = pos("1 Leg",rnds.i) rnds.i = overlay(" ",rnds.i,k) say rnds.i end else say rnds.i end say say "_______________________________________________________________________________" say say say "Best Record" say "-----------" say say "Rating = ((Goals Scored Home + (Goals Scored Away * 1.5)) / Goals Away) * Matches Played" say say "Pos Team Pld GoalsScored GoalsAgainst Rating" say "----------------------------------------------------------------------------" do i=1 to tcount say left(i,3,' ')" "bstats.i end say say "Teams Participating : "tcount say "-------------------" say do i=1 to tcount by 2 a = i + 1 say left(teams.i,30,' ')" "teams.a end say say "_______________________________________________________________________________" say if tleg_no = 0 then legged = "Blank" if tleg_no = 1 then legged = "1 Leg" if tleg_no = 2 then legged = "2 Legs" tempname = "Current Round : "bettername(word(rnds.crond,1),legged) say tempname uline = '' do i=1 to length(tempname) uline = insert('-',uline,i,1) end say strip(uline) say do i=1 to mcount if matches.i ~= "" then say matches.i end say if pos("Yes",cuph) > 0 & exists(league_file||input4_file) > 0 then do say "_______________________________________________________________________________" say say "Cup Winners" say "-----------" say if open(datafile,league_file || input4_file,'r') then do do while ~eof(datafile) line = readln(datafile) if pos(first,line) > 0 then do parse var line "*WINNER="wteam say wteam end end close(datafile) end else do say say "ERROR : (CupInformation)" say say "Unable to open '"league_file || input4_file"' file." exit end say end say "-------------------------------------------------------------------------------" say exit /* Routine ----------------------------------------------------------- */ bettername: parse arg crn,legless trdn = strip(substr(crn,1,1)) if datatype(trdn,'n') = 1 then do parse var crn roundno" "extra trn = strip(crn)" Round "extra end else do if pos("Final",crn) > 0 then do parse var crn . " "extra if pos("Replay",crn) > 0 then trn = "Final "extra else trn = "Final" end if pos("Semi",crn) > 0 then do parse var crn . " "extra if pos("Replay",crn) > 0 then trn = "Semi-Final "extra else trn = "Semi-Finals" end if pos("Quart",crn) > 0 then do parse var crn . " "extra if pos("Replay",crn) > 0 then trn = "Quarter-Final "extra else trn = "Quarter-Finals" end if pos("Third",crn) > 0 then do trn = "Third Place Play-Off" end end if pos("1 Leg",legless) > 0 then trn = trn||" (1st Leg)" if pos("2 Legs",legless) > 0 then trn = trn||" (2nd Leg)" return trn /* ------------------------------------------------------------------- */