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

  1. /* ***********************************************************************
  2.  
  3.    GAMES PLAYED PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       050197   First release.
  11.            060197   Added check so that it exits if the teams play each
  12.                     other more than twice.
  13.            110197   Forgot to initialise the variable used above. Name
  14.                     changed from 'GamesToBePlayed' to 'GamesPlayed'.
  15.            110197   Now shows all games played by selected team.
  16.            170197   Fixed bug where it displayed the team selected
  17.                     instead of skipping it.
  18.            151297   Now shows selected team's score first in Away matches
  19.                     as well. Tidied display.
  20.            210499   Added check for no team specified.
  21.  
  22. **************************************************************************
  23.  
  24. Procedure
  25. ---------
  26.  
  27. 1. Check files exist. Read Teams.df datafile and store teams.
  28. 3. Open Schedule datafile.
  29. 4. Use selected team against either HOME or AWAY team and store the score
  30.    if a match has been played. Otherwise increment matches_to_play.
  31. 5. Close file. Display data then exit...
  32.  
  33. ************************************************************************** */
  34. PARSE ARG league_stuff
  35.  
  36. version      = 1
  37. input_file   = '.df'
  38. input2_file  = '.sf'
  39. title        = '*LEAGUE_NAME='
  40. playeo       = '*PLAY_OTHER='
  41. separator    = '*'
  42. teams.       = '???'
  43. teams2.      = '???'
  44. counter      = 0
  45. not_played   = '__   __'
  46. home.        = '???'
  47. away.        = '???'
  48. numplay      = 2
  49.  
  50.  
  51. parse var league_stuff league_file search_team
  52. league_file = "Data/" || league_file
  53.  
  54. if exists(league_file || input_file) = 0  then exit
  55. if exists(league_file || input2_file) = 0 then exit
  56.  
  57. if search_team = "" then do
  58.    say
  59.    say "ERROR :    (GamesPlayed)"
  60.    say
  61.    say "Cannot view matches played as a team has not been selected."
  62.    say
  63.    say "This is a 'Set & Run' script. Program aborted."
  64.    say
  65.    exit
  66. end
  67.  
  68.  
  69. if open(datafile,league_file || input_file,'r') then do
  70.    do while ~eof(datafile)
  71.       line = readln(datafile)
  72.       if pos(title,line) > 0 then
  73.          league_title = delstr(line,1,13)
  74.       if pos(playeo,line) > 0 then
  75.          numplay = delstr(line,1,12)
  76.       if pos(separator,line) = 0 then do
  77.          line = strip(line)
  78.          if counter = 0 then do
  79.             teams.1 = line
  80.             counter = 1
  81.          end
  82.          else do
  83.             counter       = counter + 1
  84.             teams.counter = line
  85.          end
  86.       end
  87.    end
  88.    close(datafile)
  89.  
  90.    if numplay > 2 then do
  91.       say
  92.       say "ERROR :    (GamesPlayed)"
  93.       say
  94.       say "This routine only works when each team play each other twice."
  95.       exit
  96.    end
  97.  
  98.    sel=-1
  99.    search_team = strip(search_team)
  100.    do i=1 to counter
  101.       if pos(search_team,teams.i) > 0 then
  102.          sel = i
  103.    end
  104.    i   = 0
  105.    mtp = 0
  106.    if sel > 0 then do
  107.       if open(datafile,league_file || input2_file,'r') then do
  108.          do while ~eof(datafile)
  109.             line = readln(datafile)
  110.             if pos(separator,line) = 0 then do
  111.                home_team = strip(substr(line,1,30))
  112.                goals_for = strip(substr(line,32,2))
  113.                goals_aga = strip(substr(line,37,2))
  114.                away_team = strip(substr(line,41,30))
  115.  
  116.                strng = strip(teams.sel)
  117.                if strng = home_team then do
  118.                   do i=1 to counter
  119.                      if away_team = teams.i then do
  120.                         if pos(not_played,line) > 0 then
  121.                            home.i = '-'
  122.                         else do
  123.                            home.i = goals_for || "-" || goals_aga
  124.                            mtp = mtp + 1
  125.                         end
  126.                      end
  127.                   end
  128.                end
  129.                if strng = away_team then do
  130.                   do i=1 to counter
  131.                      if home_team = teams.i then do
  132.                         if pos(not_played,line) > 0 then
  133.                            away.i = '-'
  134.                         else do
  135.                            away.i = goals_aga || "-" || goals_for
  136.                            mtp = mtp + 1
  137.                         end
  138.                      end
  139.                   end
  140.                end
  141.             end
  142.          end
  143.          close(datafile)
  144.       end
  145.       else do
  146.          say
  147.          say "ERROR :    (GamesPlayed)"
  148.          say
  149.          say "Cannot read '"league_file || input2_file"' datafile."
  150.          exit
  151.       end
  152.  
  153.       say
  154.       say center("Games Played in '"league_title"'",78)
  155.       say "-------------------------------------------------------------------------------"
  156.       say
  157.       say "Team: "teams.sel"   (Team's score is ALWAYS FIRST)"
  158.       say
  159.       say
  160.       say "     Home      Away       Team"
  161.       say "     ----      ----       ----"
  162.       do i=1 to counter
  163.          if pos(teams.sel,teams.i) = 0 then
  164.             say "     "left(home.i,7)"   "left(away.i,7)"    "teams.i
  165.       end
  166.       say
  167.       say "     Matches Played: "mtp
  168.       say
  169.       say "-------------------------------------------------------------------------------"
  170.       say
  171.    end
  172.    else do
  173.       say
  174.       say "ERROR :    (GamesPlayed)"
  175.       say
  176.       say "Incorrect team. '"search_team"' cannot be found in this"
  177.       say "league."
  178.       exit
  179.    end
  180. end
  181. else do
  182.    say
  183.    say "ERROR :    (GamesPlayed)"
  184.    say
  185.    say "Cannot read '"league_file || input_file"' datafile."
  186. end
  187.  
  188. exit