home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 126
/
af126a.adf
/
Football.lzx
/
football
/
user
/
Combination.rexx
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
40KB
|
1,303 lines
/* ***********************************************************************
COMBINATION PROGRAM FOR FOOTBALL REXX SUITE
---------------------------------------------
Copyright Mark Naughton 1999
From an idea by Kevin Lambert
Version Date History
--------------------------------------------------------------------------
1.0 200499 After lifting code from other programs and tailoring
it for this, this is now ready for testing.
All working ok.
240499 Added league information from LStats.rexx.
250499 Fixed bug where percentages couldn't be calculated if
the results/matches were zero - from LStats.
**************************************************************************
Procedure
---------
1. Check files exist.
2. Check options.
3. Read league name from 'df' file.
4. Depending on options selected, run the appropriate routine. These have
not been documented as they are covered in other files.
5. Display information.
6. IF option to write the files to a directory has not been chosen,
display data.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sf'
league_file = "Data/" || league_stuff
league_title = '*LEAGUE_NAME='
separator = '*'
/*******************************************************************/
/* ** THESE PARAMETERS CAN BE CHANGED TO SUIT YOUR REQUIREMENTS ** */
/*******************************************************************/
select_fixtures = "YES" /* or "NO" */
select_statistics = "NO"
select_table = "NO"
select_leaginfo = "YES"
output_dir = "NONE" /* NONE redirects output to the */
/* console or enter complete path */
/* for files to be written */
/*******************************************************************/
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
select_fixtures = upper(select_fixtures)
select_statistics = upper(select_statistics)
select_table = upper(select_table)
select_leaginfo = upper(select_leaginfo)
if select_fixtures ~= "YES" & select_statistics ~= "YES" & select_table ~= "YES" & select_leaginfo ~= "YES" then do
say
say "ERROR : (Combination)"
say
say "No options were selected."
exit
end
if open(datafile,league_file||input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(league_title,line) > 0 then
title = delstr(line,1,13)
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input_file"' for reading."
exit
end
if select_fixtures = "YES" then
call create_fixs(league_stuff,output_dir)
if select_statistics = "YES" then
tcount = create_statistics(league_stuff,output_dir)
if select_table = "YES" then
call create_table(league_stuff,output_dir)
if select_leaginfo = "YES" then
call create_linfo(league_stuff,output_dir)
osl = 1
say
say center("Combination",78)
say "-----------------------------------------------------------------------------------------"
say
say
say center("League: "title,78)
say
say
say
if select_leaginfo = "YES" then do
if osl=1 then say "Options Selected: League Information"
osl = 0
end
if select_statistics = "YES" then do
if osl=1 then say "Options Selected: Team Statistics"
else say " Team Statistics"
osl = 0
end
if select_fixtures = "YES" then do
if osl=1 then say "Options Selected: League Fixtures"
else say " League Fixtures"
osl = 0
end
if select_table = "YES" then do
if osl=1 then say "Options Selected: League Table"
else say " League Table"
end
say
if output_dir ~= "NONE" then do
say "The following files have been written to '"output_dir"' :"
say
if select_fixtures = "YES" then say " "league_stuff".fix"
if select_statistics = "YES" then say " "league_stuff".Team<number 1-"tcount">.stat"
if select_table = "YES" then say " "league_stuff".tab"
if select_leaginfo = "YES" then say " "league_stuff".linf"
end
else do
say
say
say
if select_leaginfo = "YES" then do
say
say center("League Information",78)
say "-----------------------------------------------------------------------------------------"
say
say
if open(datafile,"RAM:"league_stuff".linf",'r') then do
do while ~eof(datafile)
line = readln(datafile)
say line
end
close(datafile)
say
say
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open 'RAM:"league_stuff".linf' file."
end
say
filen = "RAM:"league_stuff".linf"
address command 'delete >NIL: 'filen
end
if select_statistics = "YES" then do
say
say
say center("Team Statistics",78)
say "-------------------------------------------------------------------------------"
say
say
do kk=1 to tcount
if open(datafile,"RAM:"league_stuff"_Team"kk".stat",'r') then do
do while ~eof(datafile)
line = readln(datafile)
say line
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open 'RAM:"league_stuff"_Team"kk".stat' file."
end
say
filen = "RAM:"league_stuff"_Team"kk".stat"
address command 'delete >NIL: 'filen
end
end
if select_fixtures = "YES" then do
say
say
say center("League Fixtures",78)
say "-----------------------------------------------------------------------------------------"
say
say
if open(datafile,"RAM:"league_stuff".fix",'r') then do
do while ~eof(datafile)
line = readln(datafile)
say line
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open 'RAM:"league_stuff".fix' file."
end
say
filen = "RAM:"league_stuff".fix"
address command 'delete >NIL: 'filen
end
if select_table = "YES" then do
say
say
say
say center("League Table",78)
say "-----------------------------------------------------------------------------------------"
say
say
say
say " Team Pl Won Drw Lst GoalsF GoalsA Pts GoalDiff"
say "-----------------------------------------------------------------------------------------"
a = 1
if open(datafile,"RAM:"league_stuff".tab",'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= '' then do
if strip(substr(line,76,5)) = 0 then line=overlay("",line,76,5," ")
if a<10 then do
if a = 1 then line = upper(line)
say " "a") "line
end
else
say a") "line
a = a + 1
end
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open 'RAM:"league_stuff".tab' file."
end
say
filen = "RAM:"league_stuff".tab"
address command 'delete >NIL: 'filen
end
end
exit
/* Procedure --------------------------------------------------------- */
create_fixs : procedure
parse arg league_table,output_dr
league_file = "Data/"league_table
input_file = '.df'
input2_file = '.sf'
autosched = '*AUTOSCHD='
separator = '*'
autos = 0
if open(datafile,league_file||input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(autosched,line) > 0 then do
autofile = delstr(line,1,10)
autos = 1
end
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input_file"' for reading."
exit
end
file_string = "RAM:"league_table".fix"
if output_dr ~= "NONE" then
file_string = output_dr"/"league_table".fix"
if autos = 0 then do
if open(datafile,league_file || input2_file,'r') then do
if open(datafile2,file_string,'w') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
t1 = right(strip(substr(line,1,30)),30,' ')
writeln(datafile2,t1||substr(line,31))
end
else do
if words(line) > 1 then do
chas = subword(line,2)
writeln(datafile2,chas)
uline = ''
do i=1 to length(chas)
uline = insert('-',uline,i,1)
end
writeln(datafile2,strip(uline))
end
else
if words(line) = 1 then
writeln(datafile2," ")
end
end
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot write to '"file_string"'."
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input2_file"' for reading."
end
exit
end
if open(datafile,league_file || input2_file,'r') then do
if open(datafile2,file_string,'w') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
t1 = right(strip(substr(line,1,30)),30,' ')
writeln(datafile2,t1||substr(line,31))
end
else do
if words(line) > 1 then do
if pos("*Week",line) > 0 then do
chas = subword(line,2)
do mm=1 to length(chas)
if substr(chas,mm,1) = "0" then
chas = overlay(" ",chas,mm,1)
else
leave
end
chas = "Week "strip(chas)
end
else
chas = subword(line,2)
writeln(datafile2,chas)
uline = ''
do i=1 to length(chas)
uline = insert('-',uline,i,1)
end
writeln(datafile2,strip(uline))
end
else
if words(line) = 1 then
writeln(datafile2," ")
end
end
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot write to '"file_string"'."
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input2_file"' for reading."
end
return
/* Procedure --------------------------------------------------------- */
create_statistics : procedure
parse arg league_stuff,output_dr
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. = '???'
tcounter = 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
league_file = "Data/" || league_stuff
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 tcounter = 0 then do
teams.1 = line
tcounter = 1
end
else do
tcounter = tcounter + 1
teams.tcounter = line
end
end
end
close(datafile)
do jj=1 to tcounter
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
file_string = "RAM:"league_stuff"_Team"jj".stat"
if output_dr ~= "NONE" then
file_string = output_dr"/"league_stuff"_Team"jj".stat"
if open(datafile2,file_string,'w') then do
writeln(datafile2," ")
writeln(datafile2," Statistics For: "teams.jj)
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," ")
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.jj)
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)
if matches = 0 then do
writeln(datafile2," No matches yet played.")
writeln(datafile2," ")
end
else do
writeln(datafile2," Home Away")
writeln(datafile2," ")
writeln(datafile2," Pl W D L Cln Gf Ga Pts Pl W D L Cln Gf Ga Pts")
writeln(datafile2," -------------------------------------- --------------------------------------")
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)" "
writeln(datafile2,h1||h2||h3||h4||h8||h5||h6||h7||a1||a2||a3||a4||a8||a5||a6||a7)
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," ")
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
writeln(datafile2," Performance over last "matches" games: "ptemp)
else
writeln(datafile2," 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
writeln(datafile2," ")
writeln(datafile2," 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
writeln(datafile2," ")
writeln(datafile2," Away Record : "ptemp)
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," Current undefeated run : "re" games.")
writeln(datafile2," Longest undefeated run : "lre" games.")
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2," ")
end
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot read '"league_file || input2_file"' datafile."
end
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot write to '"file_string"'."
exit
end
end
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot read '"league_file || input_file"' datafile."
end
return tcounter
/* Procedure --------------------------------------------------------- */
create_linfo : procedure
parse arg league_stuff,output_dr
input_file = '.df'
input2_file = '.sflearn'
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
releg = '*RELEGATION='
playother = '*PLAY_OTHER='
promoted = '*PROMOTED='
num_divs = '*NUM_DIVISIONS='
divisions = '*DIVISIONS='
pkauthor = '* Author ='
pkversion = '* Version='
pkdate = '* Date ='
separator = '*'
not_played = '__ __'
teams. = '???'
records. = '???'
undefeat. = '???'
ustring. = '???'
rstring. = '???'
mats. = '???'
pct. = '???'
tcountr = 0
lversion = '1.0'
lreg = 2
lplayo = 2
ptsgls = 0
ndivs = 1
promo = 0
divs = ''
league_file = "Data/"league_stuff
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(pkauthor,line) > 0 then author = delstr(line,1,12)
if pos(pkversion,line) > 0 then lversion = delstr(line,1,12)
if pos(pkdate,line) > 0 then ddate = delstr(line,1,12)
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(releg,line) > 0 then lreg = delstr(line,1,12)
if pos(playother,line) > 0 then lplayo = delstr(line,1,12)
if pos(promoted,line) > 0 then promo = delstr(line,1,10)
if pos(num_divs,line) > 0 then ndivs = delstr(line,1,15)
if pos(divisions,line) > 0 then divs = delstr(line,1,11)
if pos(separator,line) = 0 then do
line = strip(line)
tcountr = tcountr + 1
teams.tcountr = strip(line)
records.tcountr = 0
undefeat.tcountr= ''
mats.tcountr = 0
pct.tcountr = 0
end
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input_file"' for reading."
exit
end
line_ct = 0
matches = 0
high_df = 0
high_ht = ''
high_at = ''
high_hw = 0
high_aw = 0
high_hs = 0
high_as = 0
draws = 0
hwins = 0
awins = 0
type = 0
hcls = 99
acls = 99
nlines. = '???'
nlcnt = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line_ct = line_ct + 1
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))
h = 0
a = 0
do i=1 to tcountr
if pos(strip(home_team),teams.i) > 0 then do
h = i
mats.i = mats.i + 1
end
if pos(strip(away_team),teams.i) > 0 then do
mats.i = mats.i + 1
a = i
end
end
if a ~= 0 & h ~= 0 then do
if goals_for > goals_aga then do
records.h = records.h + ptswin
records.a = records.a + ptslse
undefeat.h = insert('W',undefeat.h,length(undefeat.h),1)
undefeat.a = ''
end
if goals_for < goals_aga then do
records.a = records.a + ptswin
records.h = records.h + ptslse
undefeat.a = insert('W',undefeat.a,length(undefeat.a),1)
undefeat.h = ''
end
if goals_for = goals_aga then do
records.a = records.a + ptsdrw
records.h = records.h + ptsdrw
undefeat.a = insert('D',undefeat.a,length(undefeat.a),1)
undefeat.h = insert('D',undefeat.h,length(undefeat.h),1)
end
end
if home_team ~= away_team & home_team ~= '' & away_team ~= '' then
matches = matches + 1
diff = 0
if goals_for = goals_aga & home_team ~= away_team then do
draws = draws + 1
type = 0
end
if goals_for > goals_aga then do
hwins = hwins + 1
diff = goals_for - goals_aga
type = 1
end
if goals_for < goals_aga then do
awins = awins + 1
diff = goals_aga - goals_for
type = 2
end
if type = 1 then do
if diff >= high_hw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_for > high_hs) | (diff = goals_for)) | (diff = high_hw & goals_aga <= hcls) then do
high_hw = diff
hcls = goals_aga
high_hs = goals_for
high_ht = line
end
end
end
if type = 2 then do
if diff >= high_aw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_aga > high_as) | (diff = goals_aga)) | (diff = high_aw & goals_for <= acls) then do
high_as = goals_aga
high_at = line
high_aw = diff
acls = goals_for
end
end
end
type = 0
end
end
end
close(datafile)
r = 0
rcs = 0
u = 1
ucs = 0
do i=1 to tcountr
if records.i ~= 0 | mats.i ~= 0 then do
pct.i = trunc((records.i/(mats.i*ptswin) * 100),1)
if pct.i > r then r = pct.i
end
else
pct.i = "0.0"
end
do i=1 to tcountr
if pct.i = r then do
rcs = rcs + 1
rstring.rcs = teams.i || " with " || records.i || "pts from " || mats.i || " matches. ( " || pct.i || "% )"
end
end
do i=1 to tcountr
if length(undefeat.i) > u then
u = length(undefeat.i)
end
do i=1 to tcountr
if length(undefeat.i) = u then do
ucs = ucs + 1
undefeat.i=strip(undefeat.i)
ucn = (length(undefeat.i) * 2) - 1
call format_perf(undefeat.i,ucn)
if ucn = 1 then ptemp = undefeat.i
if length(ptemp) > 0 then
ustring.ucs = " " || left(teams.i,30) || " (" || ptemp || ")"
end
end
hmw = trunc((hwins/matches) * 100,1)
dm = trunc((draws/matches) * 100,1)
amw = trunc((awins/matches) * 100,1)
hwins = centre(hwins,5)
draws = centre(draws,5)
awins = centre(awins,5)
file_string = "RAM:"league_stuff".linf"
if output_dr ~= "NONE" then
file_string = output_dr"/"league_stuff".linf"
if open(datafile2,file_string,'w') then do
writeln(datafile2," ")
writeln(datafile2," Author : "author)
writeln(datafile2," Created: "ddate)
writeln(datafile2," Version: "lversion)
writeln(datafile2," ")
writeln(datafile2,"Matches played : "matches)
writeln(datafile2," ")
writeln(datafile2,"Home Wins : "hwins" ( "hmw"% )")
writeln(datafile2,"Draws : "draws" ( "dm"% )")
writeln(datafile2,"Away Wins : "awins" ( "amw"% )")
writeln(datafile2," ")
writeln(datafile2,"Points For Win : "ptswin)
writeln(datafile2,"Points For Draw : "ptsdrw)
writeln(datafile2,"Points For Loss : "ptslse)
writeln(datafile2,"Points Per Goal : "ptsgls" (NOT used for Best Record/Undefeated Run)")
writeln(datafile2," ")
writeln(datafile2,"Number of Teams Promoted : "promo)
writeln(datafile2,"Number of Teams Relegated : "lreg)
writeln(datafile2,"Play Each Team : "lplayo)
writeln(datafile2," ")
writeln(datafile2,"Number of Related Divisions: "ndivs - 1)
writeln(datafile2,"Related Divisions : "divs)
writeln(datafile2,"_______________________________________________________________________________")
writeln(datafile2," ")
writeln(datafile2,"Biggest Home Win (Priority given to teams with less goals scored against)")
writeln(datafile2,"----------------")
writeln(datafile2," ")
hline = substr(high_ht,32,2)" "substr(high_ht,37,2)
if hline ~= "" then do
do i=1 to nlcnt
if pos(hline,nlines.i) > 0 then
writeln(datafile2,nlines.i)
end
end
else
writeln(datafile2,"None found.")
writeln(datafile2," ")
writeln(datafile2,"Biggest Away Win")
writeln(datafile2,"----------------")
writeln(datafile2," ")
aline = substr(high_at,32,2)" "substr(high_at,37,2)
if aline ~= "" then do
do i=1 to nlcnt
if pos(aline,nlines.i) > 0 then
writeln(datafile2,nlines.i)
end
end
else
writeln(datafile2,"None found.")
writeln(datafile2,"_______________________________________________________________________________")
writeln(datafile2," ")
writeln(datafile2,"Best Record")
writeln(datafile2,"-----------")
writeln(datafile2," ")
do i=1 to rcs
writeln(datafile2,rstring.i)
end
writeln(datafile2," ")
writeln(datafile2," ")
writeln(datafile2,"Current Best Undefeated Run")
writeln(datafile2,"---------------------------")
writeln(datafile2," ")
ustring.1 = overlay(u || " games :",ustring.1,1)
do i=1 to ucs
writeln(datafile2,ustring.i)
end
writeln(datafile2," ")
writeln(datafile2,"-------------------------------------------------------------------------------")
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"file_string"' for writing."
exit
end
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot open '"league_file||input2_file"' for reading."
exit
end
return
/* Routine ---------------------------------------------------------- */
save_data:
PARSE ARG homet,awayt,gf,ga
h = 0
a = 0
do i=1 to tcountr
if pos(strip(homet),teams.i) > 0 then do
h = i
mats.i = mats.i + 1
end
if pos(strip(awayt),teams.i) > 0 then do
mats.i = mats.i + 1
a = i
end
end
if a = 0 | h = 0 then return
if gf > ga then do
records.h = records.h + ptswin
records.a = records.a + ptslse
undefeat.h = insert('W',undefeat.h,length(undefeat.h),1)
undefeat.a = ''
end
if gf < ga then do
records.a = records.a + ptswin
records.h = records.h + ptslse
undefeat.a = insert('W',undefeat.a,length(undefeat.a),1)
undefeat.h = ''
end
if gf = ga then do
records.a = records.a + ptsdrw
records.h = records.h + ptsdrw
undefeat.a = insert('D',undefeat.a,length(undefeat.a),1)
undefeat.h = insert('D',undefeat.h,length(undefeat.h),1)
end
return
/* Procedure --------------------------------------------------------- */
create_table : procedure
parse arg league_stuff,output_dr
input_file = '.df'
input2_file = '.sf'
not_played = '__ __'
input3_file = '.stats'
league_table = "Data/"league_stuff
output_file = 'Data/League.output'
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
team = '*TEAM='
played = '*PLY='
won = '*WIN='
drawn = '*DRW='
lost = '*LST='
goalsf = '*GOF='
goalsa = '*GOA='
points = '*PTS='
separator = '*'
teams. = '???'
teams2. = '???'
m_ply. = '???'
m_win. = '???'
m_drw. = '???'
m_lost. = '???'
m_gof. = '???'
m_goa. = '???'
m_pts. = '???'
ptsgls = 0
ptswin = 2
ptsdrw = 1
ptslse = 0
if exists(league_table || input3_file) = 0 then do
say
say "ERROR : (Combination)"
say
say "Cannot find '"league_table||input3_file"' for table creation."
exit
end
tcount = 0
if open(datafile,league_table || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
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)
tcount = tcount + 1
teams.tcount = line
end
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open '"league_table || input_file"' file."
exit
end
team_ctr = 0
if open(datafile,league_table || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(team,line) > 0 then team_ctr = team_ctr + 1
if pos(played,line) > 0 then m_ply.team_ctr = delstr(line,1,5)
if pos(won,line) > 0 then m_won.team_ctr = delstr(line,1,5)
if pos(drawn,line) > 0 then m_drw.team_ctr = delstr(line,1,5)
if pos(lost,line) > 0 then m_lost.team_ctr = delstr(line,1,5)
if pos(goalsf,line) > 0 then m_gof.team_ctr = delstr(line,1,5)
if pos(goalsa,line) > 0 then m_goa.team_ctr = delstr(line,1,5)
if pos(points,line) > 0 then m_pts.team_ctr = delstr(line,1,5)
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open '"league_table || input3_file"'."
exit
end
if open(datafile,league_table || 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))
do i=1 to tcount
if home_team = teams.i then do
m_ply.i = m_ply.i + 1
m_gof.i = m_gof.i + goals_for
m_goa.i = m_goa.i + goals_aga
if goals_for = goals_aga then do
m_drw.i = m_drw.i + 1
m_pts.i = m_pts.i + ptsdrw
end
if goals_for < goals_aga then do
m_lost.i= m_lost.i + 1
m_pts.i = m_pts.i + ptslse
end
if goals_for > goals_aga then do
m_won.i = m_won.i + 1
m_pts.i = m_pts.i + ptswin
end
m_pts.i = m_pts.i + (goals_for * ptsgls)
end
end
do i=1 to tcount
if away_team = teams.i then do
m_ply.i = m_ply.i + 1
m_gof.i = m_gof.i + goals_aga
m_goa.i = m_goa.i + goals_for
if goals_for = goals_aga then do
m_drw.i = m_drw.i + 1
m_pts.i = m_pts.i + ptsdrw
end
if goals_for < goals_aga then do
m_won.i = m_won.i + 1
m_pts.i = m_pts.i + ptswin
end
if goals_for > goals_aga then do
m_lost.i= m_lost.i + 1
m_pts.i = m_pts.i + ptslse
end
m_pts.i = m_pts.i + (goals_aga * ptsgls)
end
end
end
end
end
close(datafile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to open '"league_table || input2_file"'."
exit
end
if open(outfile,output_file,"w") then do
do i=1 to tcount
line = teams.i
line = insert(" ",line,length(line)+1,30-length(line))
mp = right(m_ply.i,3)
mw = right(m_won.i,3)
md = right(m_drw.i,3)
ml = right(m_lost.i,3)
mgf = right(m_gof.i,5)
mga = right(m_goa.i,5)
mpts = right(m_pts.i,7)
writech(outfile,line" "mp" "mw" "md" "ml" "mgf" "mga" "mpts" ")
itemp=mgf-mga
if itemp>0 then
itemp=insert("+",itemp,0,1)
itemp=right(itemp,4)
writeln(outfile,itemp)
end
close(outfile)
end
else do
say
say "ERROR : (Combination)"
say
say "Unable to update the League. Cannot write to '"output_file"'."
exit
end
address command 'Exec/footsort '
if open(datafile2,output_file,'r') then do
do i=1 to tcount
line = readln(datafile2)
teams.i = line
teams2.i = line
end
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot read '"output_file"'."
exit
end
ctr = 0
do while swapctr > 0
swapctr=9
do i=1 to tcount-1 /* was 64,4 and 77,4 */
swapdone=0
j = i + 1
if strip(substr(teams.i,64,7)) = strip(substr(teams.j,64,7)) then do
goaldiffa = strip(substr(teams.i,77,5))
goaldiffb = strip(substr(teams.j,77,5))
if goaldiffa < goaldiffb then do
teams.i = teams2.j
teams.j = teams2.i
teams2.i= teams.i
teams2.j= teams.j
swapdone= 1
ctr = ctr + 1
end
end
if swapdone = 1 then
break
end
if ctr = 0 then
swapctr = 0
else
ctr = 0
end
file_string = "RAM:"league_stuff".tab"
if output_dr ~= "NONE" then
file_string = output_dr"/"league_stuff".tab"
if open(datafile2,file_string,'w') then do
do i=1 to tcount
if strip(substr(teams.i,76,5)) = 0 then teams.i=overlay("",teams.i,76,5," ")
writeln(datafile2,teams.i)
end
close(datafile2)
end
else do
say
say "ERROR : (Combination)"
say
say "Cannot write to '"file_string"'."
exit
end
return
/* Routine ----------------------------------------------------------- */
format_perf:
ARG fstrg,counter
ptemp = ''
ii = 1
ji = 1
do while ii <= counter
ptemp = insert(substr(fstrg,ji,1),ptemp,ii,1)
ii = ii + 1
ji = ji + 1
if ii < counter then do
ptemp = insert(".",ptemp,ii,1)
ii = ii + 1
end
end
ptemp = strip(ptemp)
return
/*******************************************************************************/