home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 126
/
af126a.adf
/
Football.lzx
/
football
/
user
/
MatchAnalysis.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
12KB
|
397 lines
/* ***********************************************************************
MATCH ANALYSIS FOR FOOTBALL REXX SUITE
----------------------------------------
Copyright Mark Naughton 1997
Version Date History
--------------------------------------------------------------------------
1.0 050197 First release.
1.1 150997 Added code to handle automatic scheduling with dates.
As matches are played mid-week, it was better to get
all the games in a 7-day period than just reading the
Learn file where they are grouped together in the
number of teams divide by 2 (some games would be outside
this 7-day period). Amended displays.
1.2 250997 Amended displays of highest/lowest because when using
dates, these still gave the week numbers. Routine that
calculates the date for the listing is now a callable
procedure. Fixed bug where the program expected games
to be played every week and added games to weeks that
had no games played - the range wasn't incremented
enough.
151297 Tidied display. Added average number of goals per
game for highest/lowest.
**************************************************************************
Procedure
---------
1. Check files exist. Read Teams.df datafile and store league name.
2. If automatic scheduling, open Schedule definition file and store
whether it is run by WEEKS or DATES.
3. Open Learn file if WEEKS or non-auto sched and get statistics for
each match for each week. Close file.
4. Open '.sf' file if DATES and get statistics for each match for each
week. Increase the range from the start date as the file goes on, adding
7 days. Close file.
5. Get the highest and lowest scoring weeks.
6. Display data and exit.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
input3_file = '.sf'
title = '*LEAGUE_NAME='
autosched = '*AUTOSCHD='
separator = '*'
games. = '???'
homew. = '???'
awayw. = '???'
draws. = '???'
losses. = '???'
goalss. = '???'
weeks = 0
weekend. = '???'
months = "January February March April May June July August September October November December"
not_played = '__ __'
parse var league_stuff league_file
league_file = "Data/" || league_file
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
if exists(league_file || input3_file) = 0 then exit
autos = 0
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then
league_title = delstr(line,1,13)
if pos(autosched,line) > 0 then do
autofile = delstr(line,1,10)
autos = 1
end
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read '"league_file || input_file"' for league name."
exit
end
type = 0
if autos = 1 then do
if open(datafile,"Data/"||autofile||".schd",'r') then do
line = readln(datafile)
if pos("*WEEKS",line) > 0 then
type = 10
if pos("*DATES",line) > 0 then do
type = 20
start_date = substr(line,8,8)
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read 'Data/"autofile".schd' to check what type of"
say "schedule it is."
exit
end
end
/* use this method if its WEEKS or non-auto sched. */
if type < 20 then do
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(separator,sep) > 0 then do
weeks = weeks + 1
sep = ''
games.weeks = 0
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
end
goals_for = strip(substr(line,32,2))
goals_aga = strip(substr(line,37,2))
if datatype(goals_for,'n') = 0 | datatype(goals_aga,'n') = 0 then
leave
games.weeks = games.weeks + 1
goalss.weeks = goalss.weeks + goals_for + goals_aga
if goals_for > goals_aga then do
homew.weeks = homew.weeks + 1
losses.weeks= losses.weeks + 1
end
if goals_for = goals_aga then do
draws.weeks = draws.weeks + 1
end
if goals_for < goals_aga then do
awayw.weeks = awayw.weeks + 1
losses.weeks= losses.weeks + 1
end
end
else
sep = line
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read '"league_file || input2_file"' datafile."
exit
end
end /* DATES and automatic scheduling */
if type = 20 then do
weeks = 1
mnth = substr(start_date,3,2)
ndate= substr(start_date,5,4)||mnth||substr(start_date,1,2)
range = date('b',ndate,'s')
range = range + 6
games.weeks = 0
weekend.weeks = range
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) > 0 then do
if pos("*Date:",line) > 0 then do
year = word(line,5)
mnth = word(line,4)
day = word(line,3)
cv = 0
do i=1 to 12
if pos(mnth,word(months,i)) > 0 then do
cv = i
leave
end
end
sd = year||right(cv,2,0)||right(day,2,0)
search_date = date('b',sd,'s')
if search_date > range then do
range = range + 7
diff = 1
/* this hopes to skip weeks where no games are played. */
do while (diff > 0)
diff = search_date - range
if diff > 0 then
range = range + 7
end
weeks = weeks + 1
games.weeks = 0
weekend.weeks = range
homew.weeks = 0
awayw.weeks = 0
draws.weeks = 0
losses.weeks = 0
goalss.weeks = 0
goals_for = 0
goals_aga = 0
goals = 0
end
end
end
if pos(separator,line) = 0 & pos(not_played,line) = 0 then do
goals_for = strip(substr(line,32,2))
goals_aga = strip(substr(line,37,2))
if datatype(goals_for,'n') > 0 & datatype(goals_aga,'n') > 0 then do
games.weeks = games.weeks + 1
goalss.weeks = goalss.weeks + goals_for + goals_aga
if goals_for > goals_aga then do
homew.weeks = homew.weeks + 1
losses.weeks= losses.weeks + 1
end
if goals_for = goals_aga then do
draws.weeks = draws.weeks + 1
end
if goals_for < goals_aga then do
awayw.weeks = awayw.weeks + 1
losses.weeks= losses.weeks + 1
end
end
end
end
close(datafile)
end
else do
say
say "ERROR : (MatchAnalysis)"
say
say "Cannot read '"league_file || input3_file"' datafile."
exit
end
end
lowest = 10000
highest= 0
h = 0
l = 0
g = 0
los = 0
losc= 0
hwn = 0
hwnc= 0
awn = 0
awnc= 0
dra = 0
drac= 0
do i=1 to weeks
if games.i ~= 0 then do
if goalss.i > highest then do
highest = goalss.i
h = i
end
if goalss.i < lowest then do
lowest = goalss.i
l = i
end
g = g + games.i
if losses.i > los then do
los = losses.i
losc= i
end
if homew.i > hwn then do
hwn = homew.i
hwnc= i
end
if awayw.i > awn then do
awn = awayw.i
awnc= i
end
if draws.i > dra then do
dra = draws.i
drac= i
end
end
end
hgpmwk = 0
lgpmwk = 0
hgpm = 0
lgpm = 1000
tscr = 0
do i=1 to weeks
if games.i ~= 0 then do
tscr = trunc(goalss.i/games.i,2)
if tscr > hgpm then do
hgpm = tscr
if type < 20 then
hgpmwk = i
else
hgpmwk = weekend.i
end
if tscr < lgpm then do
lgpm = tscr
if type < 20 then
lgpmwk = i
else
lgpmwk = weekend.i
end
end
end
say
say center("Match Analysis for '"league_title"'",78)
say "-------------------------------------------------------------------------------"
say
say "Matches Played : "g
say
if type < 20 then do
say "Highest Number of Home Wins: Week No."hwnc" with "hwn" wins."
say " Away Wins: Week No."awnc" with "awn" wins."
say " Losses : Week No."losc" with "los" losses."
say " Draws : Week No."drac" with "dra" draws."
say
say "Highest Scoring: Week No."h" with "highest" goals."
say "Lowest Scoring : Week No."l" with "lowest" goals."
say
say "Highest Average Goals Per Match: Week No."hgpmwk" with "hgpm" goals per match."
say "Lowest Average Goals Per Match : Week No."lgpmwk" with "lgpm" goals per match."
end
else do
say "Highest Number of Home Wins: Week ending '"getweek(weekend.hwnc)"' with "hwn" wins."
say " Away Wins: Week ending '"getweek(weekend.awnc)"' with "awn" wins."
say " Losses : Week ending '"getweek(weekend.losc)"' with "los" losses."
say " Draws : Week ending '"getweek(weekend.drac)"' with "dra" draws."
say
say "Highest Scoring: Week ending '"getweek(weekend.h)"' with "highest" goals."
say "Lowest Scoring : Week ending '"getweek(weekend.l)"' with "lowest" goals."
say
say "Highest Average Goals Per Match: Week ending '"getweek(hgpmwk)"' with "hgpm" goals per match."
say "Lowest Average Goals Per Match : Week ending '"getweek(lgpmwk)"' with "lgpm" goals per match."
end
say
say
if type < 20 then do
say "Week No. Games Wins Goals"
say " Played Home Away Draws Losses Scored"
end
else do
say "Week Games Wins Goals"
say "Ending Played Home Away Draws Losses Scored"
end
say "--------- ------ ---------- ----- ------ ------"
say
if type < 20 then do
do i=1 to weeks
if games.i ~= 0 then
say " "left(i,6)" "left(games.i,4)" "left(homew.i,3)" "left(awayw.i,3)" "left(draws.i,4)" "left(losses.i,5)" "left(goalss.i,5)
end
end
if type = 20 then do
do i=1 to weeks
if games.i ~= 0 then do
sd = getweek(weekend.i)
say left(sd,13)" "left(games.i,4)" "left(homew.i,3)" "left(awayw.i,3)" "left(draws.i,4)" "left(losses.i,5)" "left(goalss.i,5)
end
end
end
say
say "-------------------------------------------------------------------------------"
exit
/* Procedure --------------------------------------------------------- */
getweek: procedure
parse arg days
dd = days - 722450
dd = date('n',dd,'i')
dd = delstr(dd,8,2)
return dd
/* ------------------------------------------------------------------- */