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

  1. /* ***********************************************************************
  2.  
  3.    VIEW NEXT WEEKS SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       071097   First release.
  11.            151297   Tidied display.
  12.  
  13. **************************************************************************
  14.  
  15. Procedure
  16. ---------
  17.  
  18. 1. Check files exist. Read Teams.df datafile and store league name. Check
  19.    for autoscheduled.
  20. 2. If league has not been autoscheduled then give an error and quit.
  21. 3. Open AutoSchedule file and find the type.
  22. 4. Set range for the dates.
  23. 5. Display the header.
  24. 6. Open '.sf' file. Search for matches played during the next week...
  25. 7. If Weeks, if a match is found then display the formatted data. But
  26.    when a new week is found, goto (9).
  27. 8. If Dates, format the date from the line read from the file and if
  28.    it is within the two dates, format the data and display.
  29. 9. When the file is finished, print the number of matches and exit...
  30.  
  31. ************************************************************************** */
  32. PARSE ARG league_stuff
  33.  
  34. version      = 1
  35. input_file   = '.df'
  36. input2_file  = '.sf'
  37. title        = '*LEAGUE_NAME='
  38. autosched    = '*AUTOSCHD='
  39. separator    = '*'
  40. not_played   = '__   __'
  41. months       = "January February March April May June July August September October November December"
  42.  
  43.  
  44. parse var league_stuff league_file
  45. league_file = "Data/" || league_file
  46.  
  47. if exists(league_file || input_file) = 0  then exit
  48. if exists(league_file || input2_file) = 0 then exit
  49.  
  50. autos = 0
  51. if open(datafile,league_file || input_file,'r') then do
  52.    do while ~eof(datafile)
  53.       line = readln(datafile)
  54.       if pos(title,line) > 0 then
  55.          league_title = delstr(line,1,13)
  56.       if pos(autosched,line) > 0 then do
  57.          autofile = delstr(line,1,10)
  58.          autos = 1
  59.       end
  60.    end
  61.    close(datafile)
  62. end
  63. else do
  64.    say
  65.    say "ERROR :    (ViewNextWeeksSchedule)"
  66.    say
  67.    say "Cannot read '"league_file || input_file"' for league name."
  68.    exit
  69. end
  70.  
  71. if autos = 0 then do
  72.    say
  73.    say "ERROR :    (ViewNextWeeksSchedule)"
  74.    say
  75.    say "Cannot view schedules for next week."
  76.    say
  77.    say "This program will only show schedule files that have"
  78.    say "created from a schedule definition file such as "
  79.    say "'Teams6.schd'. Program aborted."
  80.    say
  81.    exit
  82. end
  83.  
  84. type = 0
  85. if autos = 1 then do
  86.    if open(datafile,"Data/"||autofile||".schd",'r') then do
  87.       line = readln(datafile)
  88.       if pos("*WEEKS",line) > 0 then
  89.          type = 10
  90.       if pos("*DATES",line) > 0 then
  91.          type = 20
  92.       close(datafile)
  93.    end
  94.    else do
  95.       say
  96.       say "ERROR :    (ViewNextWeeksSchedule)"
  97.       say
  98.       say "Cannot read 'Data/"autofile".schd' to check what type of"
  99.       say "schedule it is."
  100.       exit
  101.    end
  102. end
  103.  
  104. start_date = date('i')
  105. end_date   = start_date + 6
  106.  
  107. say
  108. say center("Display Next Weeks Schedule for '"league_title"'",78)
  109. say "-------------------------------------------------------------------------------"
  110. say
  111. say "Created from '"autofile"' schedule defintion file."
  112. say
  113. say
  114. if type=10 then
  115.    say "Matches To Be Played Over the Next Week."
  116. else
  117.    say "Matches To Be Played Between "date('n',start_date,'i')" and "date('n',end_date,'i')"."
  118. say
  119.  
  120. matches = 0
  121. if open(datafile,league_file || input2_file,'r') then do
  122.    do while ~eof(datafile)
  123.       line = readln(datafile)
  124.       if pos(separator,line) > 0 then do
  125.          if pos("*Week:",line) > 0 then do
  126.             curr = 10
  127.             if matches > 0 then
  128.                leave
  129.          end
  130.          if pos("*Date:",line) > 0 then do
  131.             curr = 0
  132.             year = word(line,5)
  133.             mnth = word(line,4)
  134.             day  = word(line,3)
  135.             curd = trim(year)||right(find(months,mnth),2,0)||right(day,2,0)
  136.             if start_date <= date('i',curd,'s') & end_date >= date('i',curd,'s') then
  137.                curr = 10
  138.          end
  139.       end
  140.       if curr = 10 then do
  141.          if pos(separator,line) = 0 then do
  142.             if pos(not_played,line) > 0 then do
  143.                home_team = strip(substr(line,1,35))
  144.                away_team = strip(substr(line,41,35))
  145.                say left(home_team,30)" v "away_team
  146.                matches = matches + 1
  147.             end
  148.          end
  149.       end
  150.    end
  151.    close(datafile)
  152.    say
  153.    if matches = 0 then
  154.       say "No matches to be played."
  155.    else
  156.       say "Number of matches to be played:  "matches
  157.    say
  158.    say "-------------------------------------------------------------------------------"
  159.    say
  160. end
  161. else do
  162.    say
  163.    say "ERROR :    (ViewNextWeeksSchedule)"
  164.    say
  165.    say "Cannot read '"league_file || input2_file"' datafile."
  166. end
  167.  
  168. exit