home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 126
/
af126a.adf
/
Football.lzx
/
football
/
exec
/
CupUpdateMatches.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
11KB
|
352 lines
/* ***********************************************************************
CUP UPDATE MATCHES PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------------------
Copyright Mark Naughton 1997
Version Date History
--------------------------------------------------------------------------
1.0 071297 First release.
081297 Didn't write the ExtraTime and Penalties lines. While
checking through the list from '.scf', the file is
opened and each played match is written along with,
if applicable, ET and Penalties lines. Added parsing
to the matches just played to see if they fail any of
the checks.
131297 Update didn't work. Only changed the first match. Had
to rework the method to read the schedule first and
then compare it with each line in matches. Now works
properly.
141297 Added error message for Penalties.
151297 Added error message for Penalties being equal and
tidied display.
280898 Added new error messages. Added pseudo code for
addition of checks for Legs and Away Goals.
290898 Added code to parse 2nd leg matches.
050998 Amended code for away goals on extra time.
110998 Fixed major bug which rewrote the schedule file and
missed several lines. When it reached the 2nd leg of
the 2nd round, it missed the '#1st Leg' line in the
recreation of the file. Its fixed and is trimmer than
before.
120998 Amended match checking so if the score is level after
extra time with goals scored then away goals count.
**************************************************************************
Procedure
---------
1. Check files exist.
2. Read definition file and see if away goals are involved. Read in
temporary file from RAM: containing matches with scores entered from
FOOTBALL.
3. Read in '.scf' file.
4. Loop until all matches have been done; If a match hasn't been played
then overwrite it with the scores.
5. Open '.scf' file and write the newly amended data to it.
6. Exit.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = 'RAM:Football.ctmpfile'
input2_file = '.scf'
input3_file = '.cf'
matches. = '???'
separator = '*'
ttc = 0
not_played = '__ __'
league_file = "Data/"league_stuff
selines. = '???'
sdlines. = '???'
sdc = 0
awaygoals = '*CUP_AWAYG='
if exists(input_file) = 0 then exit
if exists(league_file||input2_file) = 0 then exit
if exists(league_file||input3_file) = 0 then exit
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(awaygoals,line) > 0 then awayg = delstr(line,1,11)
end
close(datafile)
end
else do
say
say "ERROR : (CupUpdateMatches)"
say
say "Unable to open '"league_file || input3_file"' file."
exit
end
ttc = 0
if open(datafile,input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= '' then do
ttc = ttc + 1
matches.ttc = line
end
end
close(datafile)
end
else do
say
say "ERROR : (CupUpdateMatches)"
say
say "Cannot open '"input_file"' for reading."
exit
end
/* parsing matches array for errors */
errors = ' '
errct = 0
legs = 0
do i=1 to ttc
mkr = 0
if pos("#Round=",matches.i) > 0 then do
if pos("1st Leg",matches.i) > 0 then
legs = 1
if pos("2nd Leg",matches.i) > 0 then
legs = 2
end
if pos('#',matches.i) = 0 then do
sh = substr(matches.i,32,2)
sa = substr(matches.i,37,2)
if sa = sh then mkr = 1
if sa ~= sh & legs~=2 then iterate
if sa ~=sh & legs=2 then mkr = 1
if pos(not_played,matches.i) > 0 then mkr = 3 /* was 0 - unsure why... */
/* this is where the check for away goals and if its equal after two legs */
/* if so then extra time then penalties needs to be played. */
/* sa and sh need to be added together with the 1st leg before checking */
/* if no winner, (if away goals set), check away goals else proceed onto */
/* extra time and penalties */
if mkr = 1 & legs = 1 then iterate
if mkr = 1 & legs = 2 then do
j = i + 1
if pos("#1st Leg",matches.j) > 0 then do
i = j
fh = substr(matches.i,32,2)
fa = substr(matches.i,37,2)
shs = fh + sh
sas = fa + sa
if shs = sas then do
if pos("YES",awayg) > 0 then do
if fh = sa then mkr = 1
if fh ~= sa then iterate
end
else
mkr = 1
end
if shs ~= sas then iterate
if pos(not_played,matches.i) > 0 then mkr = 3
end
else do
errct = errct + 1
errors = errors" "i" "
iterate
end
end
if mkr = 1 then do
j = i + 1
if pos("#Score After Extra Time",matches.j) > 0 then do
i = i + 1
eh = substr(matches.i,32,2)
ea = substr(matches.i,37,2)
if eh = "" | ea = "" then mkr = 3
if pos(not_played,matches.i) > 0 then mkr = 3
if mkr ~= 3 then do
if legs = 2 then do
shs = fh + eh
sas = fa + ea
if shs ~= sas then iterate
if pos("YES",awayg) > 0 then do
if eh = sa then do
if eh = eh & sa = ea then
mkr = 1
else
iterate
end
if eh ~= sa then iterate
end
else
mkr = 1
end
else do
if eh = ea then mkr = 1
if eh ~= ea then iterate
end
end
if eh < sh | ea < sa then mkr = 3
end
end
if mkr = 3 then do
errct = errct + 1
errors = errors" "i" "
iterate
end
if mkr = 1 then do
j = i + 1
if pos("#Penalties",matches.j) > 0 then do
i = i + 1
ph = substr(matches.i,32,2)
pa = substr(matches.i,37,2)
if ph = "" | pa = "" then mkr = 3
if ph = pa then mkr = 3
if ph ~= pa then iterate
if pos(not_played,matches.i) > 0 then mkr = 3
end
end
if mkr = 3 then do
errct = errct + 1
errors = errors" "i" "
iterate
end
end
end
if errct > 0 then do
say
say center("ERRORS FOUND WHILE UPDATING CUP '"league_stuff"'",78)
say "-------------------------------------------------------------------------------"
say
do j=1 to ttc
if pos("#Round",matches.j) = 0 then do
if pos(" "j" ",errors) > 0 then
say ">"left(matches.j,70)"< ERROR IN MATCH"
else
say ">"left(matches.j,70)"<"
end
end
say
say
say errct" errors found."
say
say "Rules"
say "-----"
say
say "1. A match fails the checks if the score is equal, extra time is"
say " equal and penalties are equal."
say "2. A match fails the checks if the score is equal and penalties"
say " are equal."
say "3. A match will fail if the score is equal and the extra time hasn't"
say " been played when it should have been."
say "4. A match will fail if the score is equal and the penalties haven't"
say " been played when they should have been."
say "5. A match will fail if the score is equal and the extra time is"
say " equal but the penalties haven't been played when they should have"
say " been."
say "6. A match will fail if the extra time scores are lower than the"
say " full-time scores."
say "7. A match will fail if it has been played over two legs and has failed"
say " checks (1) and (5)."
say "8. A match will fail if the away goals (if set) are equal with the match"
say " over two legs and has failed check (7)."
say "9. A match that is 2 legs but no score can be found for the 1st leg."
say
say "All other combinations will pass. The scores have NOT been updated so"
say "they will need to be re-entered."
say
say "-------------------------------------------------------------------------------"
exit
end
secount = 0
if open(datafile,league_file||input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
secount = secount + 1
selines.secount = line
end
close(datafile)
end
else do
say
say "ERROR : (CupUpdateMatches)"
say
say "Cannot open '"league_file||input2_file"' for reading."
exit
end
address command 'delete >NIL: 'input_file
et. = '???'
pn. = '???'
do j=1 to secount
mkr = 0
if pos(separator,selines.j) = 0 then do
shome = strip(substr(selines.j,1,30))
saway = strip(substr(selines.j,41,30))
do i=1 to ttc
home = strip(substr(matches.i,1,30))
away = strip(substr(matches.i,41,30))
mkr = 0
if shome = home & saway = away then do
if pos(not_played,selines.j) > 0 then do
selines.j = matches.i
mkr = 1
end
g = i + 1
if pos("#1st Leg",matches.g) > 0 then do
a = j + 1
dif = 1
end
else do
a = j
dif = 0
end
if mkr = 1 then do
k = i + 1 + dif
if pos("#Score After Extra Time",matches.k) > 0 & pos(not_played,matches.k) = 0 then
et.a = matches.k
k = k + 1
if pos("#Penalties",matches.k) > 0 & pos(not_played,matches.k) = 0 then
pn.a = matches.k
end
end
if mkr = 1 then leave
end
end
end
if selines.secount ~='' & selines.secount ~='*' then do
secount = secount + 1
sdlines.secount = "*"
end
if open(datafile,league_file||input2_file,'w') then do
do j=1 to secount
if selines.j~='' then do
writeln(datafile,selines.j)
if pos("???",et.j) = 0 & et.j ~= "" then
writeln(datafile,et.j)
if pos("???",pn.j) = 0 & pn.j ~= "" then
writeln(datafile,pn.j)
end
end
close(datafile)
end
else do
say
say "ERROR : (CupUpdateMatches)"
say
say "Cannot open '"league_file || input2_file"' for writing."
end
exit