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

  1. /* ***********************************************************************
  2.  
  3.    VIEW CURRENT ROUND PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       011197   First release.
  11.            141297   Wasn't working properly. It would pick up all the
  12.                     results. Changed to use method from 'CupSchedNextRnd'
  13.                     program.
  14.            151297   Added routine to improve on round name. Tidied the
  15.                     display.
  16.            260898   Amended bettername() for 1 or 2 legs.
  17.  
  18. **************************************************************************
  19.  
  20. Procedure
  21. ---------
  22.  
  23. 1. Check files exist.
  24. 2. Open working file and get current round name.
  25. 3. Open file and search for the round starting with the current name,
  26.    then print out all the matches.
  27. 4. Close file and exit.
  28.  
  29. ************************************************************************** */
  30. PARSE ARG league_file
  31.  
  32. version     = 1
  33. league_file = "Data/" || league_file
  34. input_file  = '.scf'
  35. input2_file = '.cfrw'
  36. separator   = '*'
  37. curr        = ''
  38. title       = '*CUP_TITLE='
  39. currrondn   = '*CUP_CRDN='
  40. roundddef   = '*CUP_RDEF='
  41. cuplegs     = '*CUP_LEGS='
  42.  
  43.  
  44. if exists(league_file || input_file) = 0  then exit
  45. if exists(league_file || input2_file) = 0 then exit
  46.  
  47. if open(datafile,league_file || input2_file,'r') then do
  48.    do while ~eof(datafile)
  49.       line = readln(datafile)
  50.       if pos(title,line)     > 0 then cupname = substr(line,12,35)
  51.       if pos(currrondn,line) > 0 then crondn  = strip(substr(line,11,30))
  52.       if pos(roundddef,line) > 0 then tcrondn = strip(substr(line,11,5))
  53.       if pos(cuplegs,line) > 0 then   cupleg  = strip(substr(line,11,5))
  54.    end
  55.    close(datafile)
  56. end
  57. else do
  58.    say
  59.    say "ERROR :    (ViewCupCurRound)"
  60.    say
  61.    say "Unable to open '"league_file || input2_file"' for reading."
  62.    exit
  63. end
  64.  
  65. a = 0
  66. if open(datafile,league_file || input_file,'r') then do
  67.    say
  68.    say center("Display Current Round of '"trim(cupname)"'",78)
  69.    say "-------------------------------------------------------------------------------"
  70.    say
  71.    do while ~eof(datafile)
  72.       line = readln(datafile)
  73.       if pos("*Round="strip(tcrondn),line) > 0 then do
  74.          a = 1
  75.          parse var line "*Round="tn
  76.          if pos(" Leg",tn) > 0 then do
  77.             k = pos(" Leg",tn)
  78.             tempname = "Round : "bettername(substr(tn,1,5),substr(tn,k-1,6))
  79.          end
  80.          else
  81.             tempname = "Round : "bettername(tn,"Blank")
  82.          say
  83.          say tempname
  84.          uline = ''
  85.          do i=1 to length(tempname)
  86.             uline = insert('-',uline,i,1)
  87.          end
  88.          say strip(uline)
  89.       end
  90.       if a = 1 then do
  91.          if pos(separator,line) > 0 then
  92.             say
  93.          else
  94.             say line
  95.       end
  96.    end
  97.    say
  98.    say "-------------------------------------------------------------------------------"
  99.    close(datafile)
  100. end
  101. else do
  102.    say
  103.    say "ERROR :    (ViewCupCurRound)"
  104.    say
  105.    say "Cannot open '"league_file||input_file"' for reading."
  106. end
  107.  
  108. exit
  109.  
  110. /* Routine ----------------------------------------------------------- */
  111.  
  112. bettername:
  113. parse arg crn,legless
  114.  
  115. trdn = substr(crn,1,1)
  116. if datatype(trdn,'n') = 1 then do
  117.    if pos("Replay",crn) > 0 then
  118.       trn = strip(word(crn,1))" Round "strip(word(crn,2))
  119.    else do
  120.       parse var crn roundno" "extra
  121.       trn = strip(crn)" Round "extra
  122.    end
  123. end
  124. else do
  125.    if pos("Final",crn) > 0 then do
  126.       parse var crn . " "extra
  127.       if pos("Replay",crn) > 0 then
  128.          trn = "Final "extra
  129.       else
  130.          trn = "Final"
  131.    end
  132.    if pos("Semi",crn) > 0 then do
  133.       parse var crn . " "extra
  134.       if pos("Replay",crn) > 0 then
  135.          trn = "Semi-Final "extra
  136.       else
  137.          trn = "Semi-Finals"
  138.    end
  139.    if pos("Quart",crn) > 0 then do
  140.       parse var crn . " "extra
  141.       if pos("Replay",crn) > 0 then
  142.          trn = "Quarter-Final "extra
  143.       else
  144.          trn = "Quarter-Finals"
  145.    end
  146.    if pos("Third",crn) > 0 then do
  147.       trn = "Third Place Play-Off"
  148.    end
  149. end
  150.  
  151. if pos("1 Leg",legless) > 0 then
  152.    trn = trn||"  (1st Leg)"
  153. if pos("2 Legs",legless) > 0 then
  154.    trn = trn||"  (2nd Leg)"
  155.  
  156. return trn
  157.  
  158. /* ------------------------------------------------------------------- */