CSCI 360 Spring 2014

Program 7
External Subroutines
(100 points)


Overview

For this assignment, modify program 6 to reflect that the Chicago Blackhawks have played more games during the regular season and some new players have seen some ice time.

Changes to Program 6

Input

The input file now contains 3 sets of data. The first set of data is the same as in Program 6. It represents the players that played in the first 60 games of the season. It is ended by a record with a Player Number of -1.

The second set of data holds the information for new players that have played in a game since the original set of data was compiled. As with the first set of data, each record in the second set of data represents one player and it follows the same format as the first set of data. It also is ended with a record with a Player Number of -1.

The third set of data is used to update the information from the original set of data from Program 6. Each record represents one player and reflects their statistics for the games that have been played since the original set of data was compiled. It has the following format:

columns         description
-------         -----------
 1 - 2          player number (unsigned)
 3              blank
 4 - 5          number of additional games played (unsigned)
 6              blank
 7 - 8          number of additional goals scored (unsigned)
 9              blank
10 - 11         number of additional assists (unsigned)
12              blank
13 - 15         number of additional shots taken (unsigned)
16              blank
17 - 18         change to the +/- rating (signed)
19 - 80         blank

Table Requirements

The table requirements are the same as in Program 6.

External Subroutines

For this program, modify the 3 internal subroutines from Program 6 so that they are external rather than internal, and add 2 additional external subroutines. Each of the routines must follow the standard linkage conventions that were presented in lecture.

Main routine

As mentioned above, this routine should be changed to an external subroutine.

This routine will control the flow of the program by:

The storage area for this routine is where the table, the fullword that holds the address of the next available entry, the input buffer, and the parameter list(s) should be created.

BUILD

As mentioned above, this routine should be changed to an external subroutine.

If BUILD was written correctly in Program 6, the only other change that needs to be made is to add an exit condition to the loop that puts the information into the table. The additional exit condition (besides the one that exits when end of file is reached) should exit the loop when an input record with a Player Number of -1 is found.

PRINT

Other than changing the routine to external, there are no changes that need to be made to this routine.

UPDATE

This routine will update the information for the players in the original set of data (ie. those that played in the first 16 games of the season) and produce a simple update report. It will do this by processing the third set of data in the input file.

Input Parameters for the UPDATE routine

Suggested Logic for the UPDATE routine:

1.  Initialization:  Load the input parameters

2.  Read the first update record
3.  While there are update records

4.    Implement a linear search to try to find the player with
        the same player number as on the update record

5.    If the player is found
6.      Pack the remaining values from the update record and
          add them to the corresponding values for the player
7.      Display "Player is found" on the update report

8.    Else (player is not found)
9.      Display "Player is not found" on the update report
10.   Endif

11.   Read the next update record
12. Endwhile

SORT

This routine sorts the contents of the table using the selection sort algorithm. The table should be sorted in DESCENDING order based on the number of points, which is equal to the sum of the number of goals scored and the number of assists.

Input Parameters for the SORT routine

This is the same sort that was used in Program 5. If that code was written correctly, it can be used in the this program with a few simple modifications:

Processing Requirements:

  1. All of the routines should be external. Each routine should have standard entry and exit linkage. Failure to follow this requirement will result in significant point reduction.

  2. Any and all information to be shared between routines must be passed by parameter list. This means that no routine may refer to a label outside that routine (i.e. all labels are "local" to the routine they are created in). Failure to follow this requirement will result in significant point reduction.

  3. The only items that may be "passed" to a subroutine are those listed above. You may NOT pass any extra fields!

  4. Use the following JCL statement to access the input file:

  5. //FT05F001 DD DSN=KC02330.CSCI360.FILES(DATA7),DISP=SHR

    Feel free to test the program with your own data. Simply leave out the statement above and place your data after the assembly END statement. It is important that the data you enter follows the same format as the grade run input file. For example:

             END   MAIN
    88 R Patrick Kane             59 27  36  195   H
    10 L Patrick Sharp            60 28  30  231  1Y
    19 C Jonathon Toews           60 19  36  154  2A
    81 R Marian Hossa             55 24  26  191  26
     2 D Duncan Keith             59  3  45  147  1I
    20 L Brandon Saad             60 18  22  110  2B
    -1 THIS RECORD DOES NOT GO IN THE TABLE
    12 C Peter Regin               7  2   0    9   A
    51 C Brad Mills                3  0   0    2   J
    -1 THIS RECORD DOES NOT GO IN THE TABLE
    88  9  2  3  30  J
    10  9  1  7  31  K
    19  9  8  2  25  6
    81  4  1  3   9  B 
     2  9  1  5  24  5
    20  8  1  3  24  7
    99  4  3  3  17  8
     7  9  0  3  15  F
    /*
    //
    

    Make sure that the run you hand in for grading uses the file specified above and contains nothing after the END statement.

Implementation Suggestions/Hints

Start this program by taking the code from program 6 and changing all of the internal subroutines to external. Submit the program (using the program 6 data set) and verify that the output is the same as Program 6.

Once that works, modify the BUILD routine so that the loop exits when a record with the Player Number of -1 has been read. Change the data set so that the program reads from the Program 7 data set. Submit the program and verify that the output is still the same as Program 6.

Now, add the additional call to the BUILD routine in MAIN. It should be placed between the original calls to BUILD and PRINT. Submit the program and verify that the records for the new players have been added to the table (they should be at the end).

Add the UPDATE routine and a calling statement for the routine in MAIN. Submit the program and verify that the UPDATE report is correct.

Add another call of the PRINT routine to MAIN. It should be placed after the call to UPDATE. Submit the program and verify that the original records have been correctly updated.

Finally, add the SORT routine and a calling statement in MAIN. The calling statement should be placed between the calling statements for the UPDATE and PRINT routines. Submit and verify that the output is sorted in descending order based on the number of points.

Output

The output from this program will be the three reports.

The first report is a listing of the original data from Program 6 plus the new players that have played in games since that data was compiled. It is produced by the PRINT routine and should follow the same format as in Program 6.

                                                  Chicago Blackhawks Player Stats                                                    


     #   Player                   Position       Games    Goals   Assists    Points      Shots    Shooting %   +/- Rating            
     --------------------------------------------------------------------------------------------------------------------            
     88  Patrick Kane             Right Wing       59       27       36         63        195        13.8          +8                
     10  Patrick Sharp            Left Wing        60       28       30         58        231        12.1         +18                
     19  Jonathon Toews           Center           60       19       36         55        154        12.3         +21                
     81  Marian Hossa             Right Wing       55       24       26         50        191        12.6         +26                
      2  Duncan Keith             Defense          59        3       45         48        147         2.0         +19                
     20  Brandon Saad             Left Wing        60       18       22         40        110        16.4         +22                
      7  Brent Seabrook           Defense          60        6       28         34        114         5.3         +24                
     65  Andrew Shaw              Right Wing       58       14       12         26        113        12.4         +11                
     16  Marcus Kruger            Center           60        6       18         24         60        10.0          +7                
      4  Niklas Hjalmarsson       Defense          60        4       19         23         78         5.1         +13                
      8  Nick Leddy               Defense          60        6       17         23         88         6.8         +13                
     23  Kris Versteeg            Right Wing       41        7       14         21         69        10.1          +3                
     28  Ben Smith                Right Wing       53        7       10         17         56        12.5          +3                
     27  Johnny Oduya             Defense          58        3       10         13         60         5.0          +7                
     52  Brandon Bollig           Left Wing        60        6        6         12         79         7.6          +2                
     26  Michal Handzus           Center           41        4        7         11         33        12.1          -1                
     37  Brandon Pirri            Center           28        6        5         11         34        17.6          +6                
     29  Bryan Bickell            Left Wing        43        8        2         10         63        12.7          -7                
     32  Michal Rozsival          Defense          33        1        5          6         31         3.2           0                
     11  Jeremy Morin             Left Wing        15        1        4          5         31         3.2          +2                
     17  Sheldon Brookbank        Defense          32        1        3          4         30         3.3          +4                
     42  Joakim Nordstrom         Center           10        1        1          2         10        10.0          +2                
     12  Peter Regin              Center            7        2        0          2          9        22.2          +1                
     51  Brad Mills               Center            3        0        0          0          2         0.0          -1                
      5  David Rundblad           Defense           1        0        0          0          1         0.0           0                

The second report is produced by the UPDATE routine and is simply a listing of whether or not players were found when the update records were processed. The only requirement is that the report should start at the top of a new page.

 Update results                                                                                                                      
 -------------------------                                                                                                           
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was not found                                                                                                                
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was not found                                                                                                                
 Player was not found                                                                                                                
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    
 Player was found                                                                                                                    

The third report is a listing of the updated data that has been sorted. As with the first report, it should be produced by the PRINT routine.

                                                  Chicago Blackhawks Player Stats                                                    


     #   Player                   Position       Games    Goals   Assists    Points      Shots    Shooting %   +/- Rating            
     --------------------------------------------------------------------------------------------------------------------            
     88  Patrick Kane             Right Wing       68       29       39         68        225        12.9          +7                
     10  Patrick Sharp            Left Wing        69       29       37         66        262        11.1         +16                
     19  Jonathon Toews           Center           69       27       38         65        179        15.1         +27                
     81  Marian Hossa             Right Wing       59       25       29         54        200        12.5         +28                
      2  Duncan Keith             Defense          68        4       50         54        171         2.3         +24                
     20  Brandon Saad             Left Wing        68       19       25         44        134        14.2         +29                
      7  Brent Seabrook           Defense          69        6       31         37        129         4.7         +30                
     65  Andrew Shaw              Right Wing       67       17       15         32        128        13.3         +12                
     16  Marcus Kruger            Center           69        6       20         26         72         8.3         +10                
      8  Nick Leddy               Defense          69        7       19         26        104         6.7         +13                
      4  Niklas Hjalmarsson       Defense          69        4       21         25         84         4.8         +14                
     23  Kris Versteeg            Right Wing       50        8       16         24         84         9.5          +5                
     28  Ben Smith                Right Wing       62        9       12         21         72        12.5          +6                
     27  Johnny Oduya             Defense          67        3       12         15         72         4.2          +8                
     52  Brandon Bollig           Left Wing        69        7        7         14         92         7.6          +5                
     26  Michal Handzus           Center           49        4        9         13         43         9.3           0                
     29  Bryan Bickell            Left Wing        52       10        2         12         76        13.2          -7                
     37  Brandon Pirri            Center           28        6        5         11         34        17.6          +6                
     32  Michal Rozsival          Defense          38        1        6          7         37         2.7          +4                
     11  Jeremy Morin             Left Wing        15        1        4          5         31         3.2          +2                
     17  Sheldon Brookbank        Defense          36        1        4          5         31         3.2          +3                
     42  Joakim Nordstrom         Center           10        1        1          2         10        10.0          +2                
     12  Peter Regin              Center            7        2        0          2          9        22.2          +1                
     51  Brad Mills               Center            3        0        0          0          2         0.0          -1                
      5  David Rundblad           Defense           1        0        0          0          1         0.0           0