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

  1. /* ***********************************************************************
  2.  
  3.    CUP RESULTS 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.            151297   Added routine to improve on the round names. Tidied
  12.                     display. Improved method that read the file and
  13.                     formatted it - smaller.
  14.            260898   Amended bettername() for 1 or 2 legs.
  15.  
  16. **************************************************************************
  17.  
  18. Procedure
  19. ---------
  20.  
  21. 1. Check files exist.
  22. 2. Open file and print all lines without '*' with the exception of
  23.    the league name which is underlined; possibly dates as well.
  24. 3. Also reformat "*Round" from the file into a more readable look.
  25. 3. Close file and exit.
  26.  
  27. ************************************************************************** */
  28. ARG league_file
  29.  
  30. version     = 1
  31. league_file = "Data/" || league_file
  32. input_file  = '.scf'
  33. separator   = '*'
  34.  
  35.  
  36. if exists(league_file || input_file) = 0  then exit
  37.  
  38. if open(datafile,league_file || input_file,'r') then do
  39.    say
  40.    say center("Display Cup Results...(and matches to be played)",78)
  41.    say
  42.    say center("for",78)
  43.    say
  44.    do while ~eof(datafile)
  45.       line = readln(datafile)
  46.       if pos(separator,line) = 0 then
  47.          say line
  48.       else do
  49.          if pos("**",line) > 0 then do
  50.             parse var line "** "cupname
  51.             say center(cupname,78)
  52.             say "-------------------------------------------------------------------------------"
  53.          end
  54.          else do
  55.             if pos("*Round=",line) > 0 then do
  56.                if pos("Leg",line) > 0 then do
  57.                   k = pos(" Leg",line)
  58.                   roundname = bettername(substr(line,8,5),substr(line,k-1,6))
  59.                end
  60.                else
  61.                   roundname = bettername(substr(line,8,5),"Blank")
  62.                say
  63.                say trim(roundname)
  64.                uline = ''
  65.                do i=1 to length(trim(roundname))
  66.                   uline = insert('-',uline,i,1)
  67.                end
  68.                say strip(uline)
  69.             end
  70.          end
  71.       end
  72.    end
  73.    say "-------------------------------------------------------------------------------"
  74.    close(datafile)
  75. end
  76. else do
  77.    say
  78.    say "ERROR :    (ViewCupResults)"
  79.    say
  80.    say "Cannot open '"league_file||input_file"' for reading."
  81. end
  82.  
  83. exit
  84.  
  85. /* Routine ----------------------------------------------------------- */
  86.  
  87. bettername:
  88. parse arg crn,legless
  89.  
  90. trdn = substr(crn,1,1)
  91. if datatype(trdn,'n') = 1 then do
  92.    if pos("Replay",crn) > 0 then
  93.       trn = strip(word(crn,1))" Round "strip(word(crn,2))
  94.    else do
  95.       parse var crn roundno" "extra
  96.       trn = strip(crn)" Round "extra
  97.    end
  98. end
  99. else do
  100.    if pos("Final",crn) > 0 then do
  101.       parse var crn . " "extra
  102.       if pos("Replay",crn) > 0 then
  103.          trn = "Final "extra
  104.       else
  105.          trn = "Final"
  106.    end
  107.    if pos("Semi",crn) > 0 then do
  108.       parse var crn . " "extra
  109.       if pos("Replay",crn) > 0 then
  110.          trn = "Semi-Final "extra
  111.       else
  112.          trn = "Semi-Finals"
  113.    end
  114.    if pos("Quart",crn) > 0 then do
  115.       parse var crn . " "extra
  116.       if pos("Replay",crn) > 0 then
  117.          trn = "Quarter-Final "extra
  118.       else
  119.          trn = "Quarter-Finals"
  120.    end
  121.    if pos("Third",crn) > 0 then do
  122.       trn = "Third Place Play-Off"
  123.    end
  124. end
  125.  
  126. if pos("1 Leg",legless) > 0 then
  127.    trn = trn||"  (1st Leg)"
  128. if pos("2 Legs",legless) > 0 then
  129.    trn = trn||"  (2nd Leg)"
  130.  
  131. return trn
  132.  
  133. /* ------------------------------------------------------------------- */