home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 126 / af126a.adf / Football.lzx / football / user / Cup_ViewTeamProgress.rexx < prev    next >
OS/2 REXX Batch file  |  1999-05-22  |  13KB  |  363 lines

  1. /* ***********************************************************************
  2.  
  3.    VIEW TEAM PROGRESS PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       181297   First release.
  11.            140998   Added support for Two-Leg matches and Away Goals.
  12.            210499   Added check for no team specified.
  13.  
  14. **************************************************************************
  15.  
  16. Procedure
  17. ---------
  18.  
  19. 1. Check files exist.
  20. 2. Read '.cf' file and get cup name and team list.
  21. 3. Search for selected team and give error if cannot find it, else set
  22.    marker.
  23. 4. Read '.scf' file and read in all round names and matches that the
  24.    selected team was in.
  25. 5. Display title.
  26. 6. Loop. Get roundname and change if replay. Get Home and Away type.
  27. 7. Read match and get opponent and score, adding it to goals conceeded
  28.    and goals scored.
  29. 8. Check next line for Extra Time, and append to score string. Change
  30.    goals_con/scored accordingly.
  31. 9. Check next line for Penalties, and append to score string.
  32. 10.Display round, home/away, opponent and score.
  33. 11.End loop.
  34. 12.Exit.
  35.  
  36. ************************************************************************** */
  37. PARSE ARG league_stuff
  38.  
  39. version      = 1
  40. input_file   = '.cf'
  41. input2_file  = '.scf'
  42. separator    = '*'
  43. matches.     = '???'
  44. mcount       = 0
  45. not_played   = '__   __'
  46. teams.       = '???'
  47. counter      = 0
  48. title        = '*CUP_TITLE='
  49. awaygs       = '*CUP_AWAYG='
  50.  
  51.  
  52. parse var league_stuff league_file search_team
  53. league_file = "Data/" || league_file
  54.  
  55. if exists(league_file || input_file) = 0  then exit
  56. if exists(league_file || input2_file) = 0 then exit
  57.  
  58. if search_team = "" then do
  59.    say
  60.    say "ERROR :    (ViewTeamProgress)"
  61.    say
  62.    say "Cannot view team's progress as none was selected."
  63.    say
  64.    say "This is a 'Set & Run' script. Program aborted."
  65.    say
  66.    exit
  67. end
  68.  
  69.  
  70. if open(datafile,league_file || input_file,'r') then do
  71.    do while ~eof(datafile)
  72.       line = readln(datafile)
  73.       if pos(title,line) > 0 then        cupname= delstr(line,1,11)
  74.       if pos(awaygs,line) > 0 then       awayg  = delstr(line,1,11)
  75.       if pos(separator,line) = 0 then do
  76.          line = strip(line)
  77.          if counter = 0 then do
  78.             teams.1 = line
  79.             counter = 1
  80.          end
  81.          else do
  82.             counter       = counter + 1
  83.             teams.counter = line
  84.          end
  85.       end
  86.    end
  87.    close(datafile)
  88. end
  89. else do
  90.    say
  91.    say "ERROR :    (ViewTeamProgress)"
  92.    say
  93.    say "Cannot open '"league_file||input_file"' for reading."
  94.    exit
  95. end
  96.  
  97. sel=-1
  98. search_team = strip(search_team)
  99. do i=1 to counter
  100.    if pos(search_team,teams.i) > 0 then
  101.       sel = i
  102. end
  103. if sel < 0 then do
  104.    say
  105.    say "ERROR :    (ViewTeamProgress)"
  106.    say
  107.    say "Incorrect team. '"search_team"' cannot be found in this"
  108.    say "cup."
  109.    exit
  110. end
  111.  
  112. if open(datafile,league_file || input2_file,'r') then do
  113.    do while ~eof(datafile)
  114.       line = readln(datafile)
  115.       if pos("*Round",line) > 0 then do
  116.          mcount = mcount + 1
  117.          matches.mcount = line
  118.       end
  119.       if pos(separator,line) = 0 & pos("#",line) = 0 then do
  120.          line = strip(line)
  121.          if pos(teams.sel,line) > 0 then do
  122.             mcount = mcount + 1
  123.             matches.mcount = line
  124.             mkr = 1
  125.          end
  126.          else
  127.             mkr = 0
  128.       end
  129.       if pos("#",line) > 0 & mkr = 1 then do
  130.          mcount = mcount + 1
  131.          matches.mcount = line
  132.       end
  133.    end
  134.    close(datafile)
  135. end
  136. else do
  137.    say
  138.    say "ERROR :    (ViewTeamProgress)"
  139.    say
  140.    say "Cannot open '"league_file||input2_file"' for reading."
  141.    exit
  142. end
  143.  
  144. say
  145. say center("'"cupname"'",78)
  146. say "-------------------------------------------------------------------------------"
  147. say
  148. say "Team : "teams.sel
  149. say
  150. say
  151. say "Round          Where?  Match        (The selected team's score is always first)"
  152. say "-------------------------------------------------------------------------------"
  153. say
  154. goals_con = 0
  155. goals_scr = 0
  156. donem = 0
  157.  
  158. do i=1 to mcount
  159.    if pos("*Round",matches.i) > 0 then do
  160.       if pos("Replay",matches.i) > 0 then
  161.          round = left("Replay",15,' ')
  162.       else do
  163.          parse var matches.i "*Round="name
  164.          round = substr(name,1,5)
  165.          if pos("1 Leg",name) > 0 then round = round||" (1st L)"
  166.          if pos("2 Legs",name) > 0 then round = round||" (2nd L)"
  167.          round = left(round,15,' ')
  168.       end
  169.       donem = 0
  170.       h = 0
  171.       j = i + 1
  172.       if pos(teams.sel,matches.j) = 1 then do
  173.          round = round||"Home    "
  174.          h = 1
  175.          donem = 1
  176.       end
  177.       if pos(teams.sel,matches.j) > 1 then do
  178.          round = round||"Away    "
  179.          h = 2
  180.          donem = 1
  181.       end
  182.       if donem = 1 then do
  183.          if pos(not_played,matches.j) > 0 then do
  184.             if h = 1 then opponent = strip(substr(matches.j,41,30))
  185.             if h = 2 then opponent = strip(substr(matches.j,1,30))
  186.             say round""left(opponent,32)"     -  To Be Played."
  187.          end
  188.          else do
  189.             sd = ''
  190.             if pos("2 Legs",name) > 0 then do
  191.                for = strip(substr(matches.j,32,2))
  192.                aga = strip(substr(matches.j,37,2))
  193.                if h = 1 then do
  194.                   sd = right(for,2)"-"left(aga,2)
  195.                   goals_scr = goals_scr + for
  196.                   goals_con = goals_con + aga
  197.                   opponent = strip(substr(matches.j,41,30))
  198.                end
  199.                else do
  200.                   sd = right(aga,2)"-"left(for,2)
  201.                   goals_scr = goals_scr + aga
  202.                   goals_con = goals_con + for
  203.                   opponent = strip(substr(matches.j,1,30))
  204.                end
  205.                k = j + 1
  206.                if pos("#1st Leg",matches.k) > 0 then do
  207.                   parse var matches.k "#1st Leg" for1l aga1l .
  208.                   for1l = strip(for1l)
  209.                   aga1l = strip(aga1l)
  210.                   if h = 1 then
  211.                      sd = sd"  Agg: "right(for1l+for,2)"-"left(aga1l+aga,2)
  212.                   else
  213.                      sd = sd"  Agg: "right(aga1l+aga,2)"-"left(for1l+for,2)
  214.                   if (for1l+for) = (aga + aga1l) then do
  215.                      if pos("YES",awayg) > 0 then do
  216.                         if for1l > aga then do
  217.                            if h = 1 then
  218.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals."
  219.                            else
  220.                               extra_line = "                                                                 "opponent" win on Away goals."
  221.                            np = 1
  222.                         end
  223.                         if for1l < aga then do
  224.                            if h = 1 then
  225.                               extra_line = "                                                                 "opponent" win on Away goals."
  226.                            else
  227.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals."
  228.                            np = 1
  229.                         end
  230.                      end
  231.                   end
  232.                end
  233.                k = k + 1
  234.                if pos("#Score After Extra Time",matches.k) > 0 then do
  235.                   for1 = strip(substr(matches.k,32,2))
  236.                   aga1 = strip(substr(matches.k,37,2))
  237.                   if h = 1 then do
  238.                      sd = sd".  AET: "right(for1,2)"-"left(aga1,2)"   Agg: "right(for1l+for1,2)"-"left(aga1l+aga1,2)
  239.                      goals_scr = goals_scr - for + for1
  240.                      goals_con = goals_con - aga + aga1
  241.                   end
  242.                   else do
  243.                      sd = sd".  AET: "right(aga1,2)"-"left(for1,2)"   Agg: "right(aga1l+aga1,2)"-"left(for1l+for1,2)
  244.                      goals_scr = goals_scr - aga + aga1
  245.                      goals_con = goals_con - for + for1
  246.                   end
  247.                   if (for1+for1l) = (aga1 + aga1l) then do
  248.                      if pos("YES",awayg) > 0 then do
  249.                         if for1 > aga then do
  250.                            if h = 1 then
  251.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals,"
  252.                            else
  253.                               extra_line = "                                                                 "opponent" win on Away goals,"
  254.                            extra_line2= "                                                                 "after Extra Time."
  255.                            np = 2
  256.                         end
  257.                         if for1 < aga then do
  258.                            if h = 1 then
  259.                               extra_line = "                                                                 "opponent" win on Away goals,"
  260.                            else
  261.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals,"
  262.                            extra_line2= "                                                                 "after Extra Time."
  263.                            np = 2
  264.                         end
  265.                      end
  266.                   end
  267.                   k = k + 1
  268.                   if pos("#Penalties",matches.k) > 0 then do
  269.                      for1 = strip(substr(matches.k,32,2))
  270.                      aga1 = strip(substr(matches.k,37,2))
  271.                      sd = sd||","
  272.                      if h = 1 then
  273.                         extra_line3 = "                                                                 After Penalties: "right(for1,2)"-"left(aga1,2)
  274.                      else
  275.                         extra_line3 = "                                                                 After Penalties: "right(aga1,2)"-"left(for1,2)
  276.                      np = 3
  277.                   end
  278.                end
  279.                else do
  280.                   if pos("#Penalties",matches.k) > 0 then do
  281.                      for1 = strip(substr(matches.k,32,2))
  282.                      aga1 = strip(substr(matches.k,37,2))
  283.                      if h = 1 then
  284.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  285.                      else
  286.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  287.                   end
  288.                end
  289.             end
  290.             if pos("2 Legs",name) = 0 then do
  291.                for = strip(substr(matches.j,32,2))
  292.                aga = strip(substr(matches.j,37,2))
  293.                if h = 1 then do
  294.                   sd = right(for,2)"-"left(aga,2)
  295.                   goals_scr = goals_scr + for
  296.                   goals_con = goals_con + aga
  297.                   opponent = strip(substr(matches.j,41,30))
  298.                end
  299.                else do
  300.                   sd = right(aga,2)"-"left(for,2)
  301.                   goals_scr = goals_scr + aga
  302.                   goals_con = goals_con + for
  303.                   opponent = strip(substr(matches.j,1,30))
  304.                end
  305.                g = j + 1
  306.                if pos("#Score After Extra Time",matches.g) > 0 then do
  307.                   for1 = strip(substr(matches.g,32,2))
  308.                   aga1 = strip(substr(matches.g,37,2))
  309.                   if h = 1 then do
  310.                      sd = sd"  AET: "right(for1,2)"-"left(aga1,2)
  311.                      goals_scr = goals_scr - for + for1
  312.                      goals_con = goals_con - aga + aga1
  313.                   end
  314.                   else do
  315.                      sd = sd"  AET: "right(aga1,2)"-"left(for1,2)
  316.                      goals_scr = goals_scr - aga + aga1
  317.                      goals_con = goals_con - for + for1
  318.                   end
  319.                   g = g + 1
  320.                   if pos("#Penalties",matches.g) > 0 then do
  321.                      for1 = strip(substr(matches.g,32,2))
  322.                      aga1 = strip(substr(matches.g,37,2))
  323.                      if h = 1 then
  324.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  325.                      else
  326.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  327.                   end
  328.                end
  329.                else do
  330.                   if pos("#Penalties",matches.g) > 0 then do
  331.                      for1 = strip(substr(matches.g,32,2))
  332.                      aga1 = strip(substr(matches.g,37,2))
  333.                      if h = 1 then
  334.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  335.                      else
  336.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  337.                   end
  338.                end
  339.             end
  340.             say round""left(opponent,32)"   "sd
  341.             if np > 0 then do
  342.                if np = 3 then say extra_line3
  343.                if np = 1 | np = 2 then say extra_line
  344.                if np = 2 then say extra_line2
  345.                np = 0
  346.             end
  347.             donem = 0
  348.          end
  349.       end
  350.    end
  351. end
  352. say
  353. say
  354. say
  355. say "Goals Scored    : "goals_scr
  356. say "Goals Conceeded : "goals_con
  357. say
  358. say
  359. say "-------------------------------------------------------------------------------"
  360.  
  361. exit
  362.  
  363. /*************************************************************************************/