/* *********************************************************************** GAMES PROGRAM FOR FOOTBALL REXX SUITE ------------------------------------------- Copyright Mark Naughton 1996 Version Date History -------------------------------------------------------------------------- 1.0 230996 First release. Finished putting in code to display fixtures. Started 17/09/96. Added whether its a WIN, a DRAW or LOST to output. Added error check in case the selected team was incorrect. 270996 Updated to use new filenames. Improved error messages. 300996 Tidied code slightly. Added error message. 1.1 111196 Updated to use different leagues and to become a component called by FOOTBALL. Changed to read info from '*.sflearn' as this data is in the correct order. Gets team name from argument. 131196 Added checks for files - if not found, exits without a message. 211196 Updated and tidied the display. 190497 Added title to display. 1.2 150997 Added code to handle dates/weeks from Automatic- Scheduling. Tidied display and added headings. 151297 Tidied display. 050599 Amended display. 250899 Added error msg to file checks. 270899 Converted to use locale. Some error messages, before reading the locale, will still be in English. 010999 Converted to use a global date format file. Now correctly translates date format to get required data. 050999 Found a problem where if the datafile was created with a different locale, you wouldn't be able to read it so now we read through the control files for all locales making sure we find the correct date data. ************************************************************************** Procedure --------- 1. Check files exist. Read Teams.df datafile and store teams. 2. Search for specified team and if not found, give an error and quit. 3. Open datafile depending whether it was autoscheduled or not. 4. If "Week" or "Date" is found, grab the data and format it for later. 5. Use selected team against either HOME or AWAY team and if a match is found then display the data. 6. When the file is finished, print the number of matches and exit... ************************************************************************** */ PARSE ARG league_stuff version = 1 input_file = '.df' input2_file = '.sflearn' input3_file = '.sf' title = '*LEAGUE_NAME=' autosched = '*AUTOSCHD=' separator = '*' teams. = '???' counter = 0 not_played = '__ __' parse var league_stuff league_file search_team league_file = "Data/" || league_file if open(datafile,"Data/Football.locale",'r') then do line = readln(datafile) locdir = strip(line) close(datafile) end else do say say "ERROR : (Games)" say say "Cannot read 'Data/Football.locale' for the locale settings." exit end dfordir = locdir"Football.locale_data" locdir = locdir"Exec/Games.data" if open(datafile,"ENV:FootballRXPath",'r') then do line = readln(datafile) rxdir = strip(line) close(datafile) end else rxdir = "SYS:Rexxc/" if exists(locdir) > 0 then do address command rxdir'rx 'locdir VarCount = getclip('VarCount') do i = 1 to VarCount interpret getclip('var.'i) end end else do say say "ERROR : (Games)" say say "Cannot find '"locdir"' to read locale settings." exit end if exists(dfordir) > 0 then do address command rxdir'rx 'dfordir VarCount = getclip('VarCount') do i = 1 to VarCount interpret getclip('var.'i) end end else do say say "ERROR : (Games)" say say "Cannot find '"dfordir"' to read date locale settings." exit end if exists(league_file || input_file) = 0 then do say say gm_error say say fl_canfd"'"league_file||input_file"'." exit end if exists(league_file || input2_file) = 0 then do say say gm_error say say fl_canfd"'"league_file||input2_file"'." exit end if exists(league_file || input3_file) = 0 then do say say gm_error say say fl_canfd"'"league_file||input3_file"'." exit end autos = 0 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(autosched,line) > 0 then autos = 1 if pos(separator,line) = 0 then do line = strip(line) if counter = 0 then do teams.1 = line counter = 1 end else do counter = counter + 1 teams.counter = line end end end close(datafile) sel=-1 search_team = strip(search_team) do i=1 to counter if pos(search_team,teams.i) > 0 then sel = i end if sel > 0 then do say say center(gm_two"'"league_title"'",78) say "-------------------------------------------------------------------------------" say say gm_three""teams.sel say gm_four say matches = 0 if autos = 1 then do file_to_open = league_file || input3_file say gm_five say "-----------------------------------------------------------------------------" end else do file_to_open = league_file || input2_file say gm_six say "-----------------------------------------------------------------------------" end if open(datafile,file_to_open,'r') then do do while ~eof(datafile) line = readln(datafile) if autos = 1 then do if pos(separator,line) > 0 then do if pos("*Week:",line) > 0 then do curr = subword(line,2) end s_l = 0 if pos("*Date:",line) > 0 then do if s_l = 0 then do parse var line "*Date:" dateall search_loc = strip(word(dateall,words(dateall)-1)) do mnls=1 to 12 if pos(word(months,mnls),search_loc) > 0 then do s_l = 1 leave end end if s_l = 0 then do locale_cats = showdir("Locale/") do search_locale=1 to words(locale_cats) dfordir = "Locale/"word(locale_cats,search_locale)"/Football.locale_data" if exists(dfordir) > 0 then do address command rxdir'rx 'dfordir VarCount = getclip('VarCount') do i = 1 to VarCount interpret getclip('var.'i) end end parse var line "*Date:" dateall search_loc = strip(word(dateall,words(dateall)-1)) do mnls=1 to 12 if pos(word(months,mnls),search_loc) > 0 then do s_l = 1 leave end end if s_l = 1 then leave end end if s_l > 0 then do temp_dtal = dateall parse var date_format "day" sp1 "number" sp2 "month" sp3 "year" parse var line "*Date:" dateall do i=1 to 7 if pos(word(days,i),dateall) > 0 then do lk = pos(word(days,i),dateall) dateall = delstr(dateall,1,lk+length(word(days,i))+length(sp1)-1) end end dateall = strip(dateall) year = word(dateall,words(dateall)) mnth = strip(word(dateall,words(dateall)-1)) do lm=1 to length(mnth) if datatype(substr(mnth,1,1),'m') ~= 1 then mnth = delstr(mnth,1,1) end mnth = substr(mnth,1,3) dateall = temp_dtal day = word(dateall,2) do lm=1 to length(day)-2 if datatype(substr(day,3,1),'n') ~= 1 then day = delstr(day,3,1) end cv = 0 do i=1 to 12 if pos(word(months,i),mnth) > 0 then do cv = i leave end end end end if s_l = 0 then do say say ma_t1 say say ma_t11 exit end curr = right(day,2,0)" "mnth" "substr(year,3,2) end end end else curr = '' 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.sel) if strng = home_team then do if goals_for > goals_aga then ttemp = gm_fourteen if goals_for = goals_aga then ttemp = gm_fifteen if goals_for < goals_aga then ttemp = gm_sixteen if autos = 1 then say left(curr,15)""gm_seven""left(away_team,30)" "goals_for" -"goals_aga" "right(ttemp,12) else say gm_seven""left(away_team,30)" "goals_for" -"goals_aga" "right(ttemp,12) matches = matches + 1 end if strng = away_team then do if goals_for > goals_aga then ttemp = gm_sixteen if goals_for = goals_aga then ttemp = gm_fifteen if goals_for < goals_aga then ttemp = gm_seventeen if autos = 1 then say left(curr,15)""gm_eight""left(home_team,30)" "goals_aga" -"goals_for" "right(ttemp,12) else say gm_eight""left(home_team,30)" "goals_aga" -"goals_for" "right(ttemp,12) matches = matches + 1 end end end end close(datafile) say if matches = 0 then say gm_nine else say gm_ten""matches say say "-------------------------------------------------------------------------------" say end else do say say gm_error say say fl_canread"'"league_file || input2_file"'." exit end end else do say say gm_error say say fl_iteam"'"search_team"'"fl_canleag exit end end else do say say gm_error say say fl_canread"'"league_file || input_file"'." end exit