home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 126
/
af126a.adf
/
Football.lzx
/
football
/
exec
/
Stats.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
11KB
|
341 lines
/* ***********************************************************************
STATS PROGRAM FOR FOOTBALL REXX SUITE
---------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 270996 First release.
300996 Amended display for Performance. Tidied some code and
added an error message.
1.1 111196 Added to Football as a callable component. Amended for
different leagues. Fixed bug where if one match was
played, the performance wasn't shown. Fixed bug where
the longest performance record wasn't correctly done.
Removed messages.
131196 Added checks for files - if not found, exits without
a message.
181196 Fixed bug where if 3 matches had been played, the
performance was not printed correctly as the number
of iterations required to format it was wrong.
201196 Added code to display home and away performance.
211196 Updated and tidied the display.
1.2 110497 Added code to support Points_Per_Goals.
151297 Tidied display.
1.3 190499 Added clean sheet to stats and added Key. Remoulded
the display.
**************************************************************************
Procedure
---------
1. Check files exist. Read Teams.df datafile and store teams and points.
2. Close file. Prompt user for a team to display fixtures for.
3. Display data and open 'Teams.sflearn'.
4. Read data about matches that the selected team has played and store it.
This applies to both home and away matches even though the data is on
different panels.
5. Close file and then display data.
6. Calculate record and performance and then display these. Then exit...
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
title = '*LEAGUE_NAME='
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
separator = '*'
teams. = '???'
counter = 0
not_played = '__ __'
hplay = 0
hwin = 0
hdraw = 0
hloss = 0
hgoals = 0
hagoals = 0
hpts = 0
hcls = 0
aplay = 0
awin = 0
adraw = 0
aloss = 0
agoals = 0
aagoals = 0
apts = 0
acls = 0
ptsgls = 0
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
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(points_win,line) > 0 then ptswin=delstr(line,1,16)
if pos(points_drw,line) > 0 then ptsdrw=delstr(line,1,16)
if pos(points_lse,line) > 0 then ptslse=delstr(line,1,16)
if pos(points_gls,line) > 0 then ptsgls=delstr(line,1,16)
if pos(separator,line) = 0 then do
line = strip(line)
if counter = 0 then do
teams.1 = line
counter = 1
end
else do
counter = counter + 1
teams.counter = line
end
end
end
close(datafile)
sel=-1
search_team = strip(search_team)
do i=1 to counter
if pos(search_team,teams.i) > 0 then sel = i
end
if sel > 0 then do
say
say center("Display Team Statistics in '"league_title"'",78)
say "-------------------------------------------------------------------------------"
say
say
say " Statistics For: "upper(teams.sel)
say
say
say
matches = 0
lrecord = ''
awayperf= ''
homeperf= ''
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(not_played,line) = 0 then do
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
strng = strip(teams.sel)
if strng = home_team then do
if goals_aga = 0 then
hcls = hcls + 1
if goals_for > goals_aga then do
hwin = hwin + 1
ltemp = 'W'
hpts = hpts + ptswin
end
if goals_for = goals_aga then do
hdraw = hdraw + 1
ltemp = 'D'
hpts = hpts + ptsdrw
end
if goals_for < goals_aga then do
hloss = hloss + 1
ltemp = 'L'
hpts = hpts + ptslse
end
lrecord = insert(ltemp,lrecord,matches+1,1)
homeperf= insert(ltemp,homeperf,hplay+1,1)
hgoals = hgoals + goals_for
hagoals = hagoals+ goals_aga
hplay = hplay + 1
matches = matches + 1
hpts = hpts + (goals_for * ptsgls)
end
if strng = away_team then do
if goals_for = 0 then
acls = acls + 1
if goals_for > goals_aga then do
aloss = aloss + 1
ltemp = 'L'
apts = apts + ptslse
end
if goals_for = goals_aga then do
adraw = adraw + 1
ltemp = 'D'
apts = apts + ptsdrw
end
if goals_for < goals_aga then do
awin = awin + 1
ltemp = 'W'
apts = apts + ptswin
end
lrecord = insert(ltemp,lrecord,matches+1,1)
awayperf= insert(ltemp,awayperf,aplay+1,1)
agoals = agoals + goals_aga
aagoals = aagoals+ goals_for
aplay = aplay + 1
matches = matches + 1
apts = apts + (goals_aga * ptsgls)
end
end
end
end
close(datafile)
say
if matches = 0 then do
say " No matches yet played."
say
end
else do
say " Home Away"
say
say " Pl W D L Cln Gf Ga Pts Pl W D L Cln Gf Ga Pts"
say " -------------------------------------- --------------------------------------"
h1 = " "left(hplay,3)" "
h2 = left(hwin,3)" "
h3 = left(hdraw,3)" "
h4 = left(hloss,3)" "
h5 = left(hgoals,4)" "
h6 = left(hagoals,4)" "
h7 = left(hpts,6)" "
h8 = left(hcls,4)" "
a1 = left(aplay,3)" "
a2 = left(awin,3)" "
a3 = left(adraw,3)" "
a4 = left(aloss,3)" "
a5 = left(agoals,4)" "
a6 = left(aagoals,4)" "
a7 = left(apts,6)
a8 = left(acls,4)" "
say h1||h2||h3||h4||h8||h5||h6||h7||a1||a2||a3||a4||a8||a5||a6||a7
say
say
say
say
say
re = 0
lre = 0
do i=1 to matches+1
if substr(lrecord,i,1) = 'W' then re = re + 1
if substr(lrecord,i,1) = 'D' then re = re + 1
if substr(lrecord,i,1) = 'L' then do
if re > lre then lre = re
re = 0
end
end
if lre = 0 then lre = re
lrecord = strip(lrecord)
countr = (matches * 2) - 1
if matches > 8 then do
lrecord = right(lrecord,8)
countr = 15
end
call format_perf(lrecord,countr)
if countr = 1 then ptemp = lrecord
if matches < 9 then
say " Performance over last "matches" games: "ptemp
else
say " Performance over last 8 games: "ptemp
homeperf=strip(homeperf)
hcountr = (hplay * 2) - 1
if hplay > 8 then do
homeperf = right(homeperf,8)
hcountr = 15
end
call format_perf(homeperf,hcountr)
if hplay = 1 then ptemp = homeperf
say
say " Home Record : "ptemp
awayperf=strip(awayperf)
acountr = (aplay * 2) - 1
if aplay > 8 then do
awayperf = right(awayperf,8)
acountr = 15
end
call format_perf(awayperf,acountr)
if aplay = 1 then ptemp = awayperf
say
say " Away Record : "ptemp
say
say
say
say " Current undefeated run : "re" games."
say " Longest undefeated run : "lre" games."
say
say
say
say
say
say
say
say
say
end
say "-------------------------------------------------------------------------------"
say "Key:"
say " Pl Played Gf Goals For"
say " W Win Ga Goals Against"
say " D Draw Pts Points"
say " L Loss"
say " Cln Clean Sheet"
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot read '"league_file || input2_file"' datafile."
exit
end
end
else do
say
say "ERROR : (Stats)"
say
say "Incorrect team. '"search_team"' cannot be found in this"
say "league."
exit
end
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot read '"league_file || input_file"' datafile."
end
exit
/* Routine ----------------------------------------------------------- */
format_perf:
ARG fstrg,counter
ptemp = ''
i = 1
j = 1
do while i <= counter
ptemp = insert(substr(fstrg,j,1),ptemp,i,1)
i = i + 1
j = j + 1
if i < counter then do
ptemp = insert(".",ptemp,i,1)
i = i + 1
end
end
ptemp = strip(ptemp)
return
/* ------------------------------------------------------------------- */