10 REM PRINT FINAL STANDINGS SHEET     (FINAL)
12 REM Developed by William W. Klaproth,  Moraga Ca.  94556    September 1982
20 REM MASTER FILE DESCRIPTIONS FOR ALL BOWLING PROGRAMS
30 OPEN "B:TEAMS.HDR" AS #1 LEN = 64
40 FIELD #1, 2 AS TM$, 30 AS NAM$, 2 AS RCNT$, 2 AS GAM$, 4 AS PINS$, 2 AS AVG$, 2 AS HIG$, 2 AS HIS$, 4 AS PTSW$, 4 AS PTSL$, 2 AS B1ID$, 2 AS B2ID$, 2 AS B3ID$, 2 AS B4ID$, 2 AS B5ID$
50 FIELD #1, 2 AS HDRID$, 30 AS LEAGUE$, 2 AS WEEKS$, 2 AS TEAMS$, 4 AS FILLER$, 2 AS BWLPERTM$, 2 AS NXTID$, 2 AS HCPBASE$, 4 AS HCPPCNT$
60 OPEN "B:BOWLERS.HDR" AS #2 LEN = 64
70 FIELD #2, 2 AS BBO$, 30 AS BNAM$, 2 AS BRCNT$, 2 AS BGAM$, 4 AS BPINS$, 2 AS BAVG$, 2 AS BHIG$, 2 AS BHIS$, 2 AS BHCP$, 2 AS BHIGH$, 2 AS BHISH$, 2 AS BTM$,2 AS GAM2$, 2 AS SER5$, 2 AS SER6$,2 AS CURSER$,2 AS AVGLSTYR$
80 REM OPEN "B:TEAM.DET" AS #3 LEN = 16
90 REM FIELD #3,2 AS DTM$, 2 AS TMO$, 2 AS TDAY$, 2 AS TG1$, 2 AS TG2$, 2 AS TG3$, 2 AS TSER$, 2 AS DPTSW$
100 REM OPEN "B:BOWLER.DET" AS #4 LEN = 16
110 REM FIELD #4,2 AS DBO$, 2 AS BMO$, 2 AS BDAY$, 2 AS BG1$, 2 AS BG2$, 2 AS BG3$, 2 AS BSER$
120 CLS
130 PRINT "PRINT FINAL STANDINGS"
140 GET #1,1
150 TEAMS% = CVI(TEAMS$)
160 WEEKS% = CVI(WEEKS$)
170 BOWLERS% = CVI(BWLPERTM$)
180 NEXTID% = CVI(NXTID$)
190 DIM TM%(TEAMS%)
200 DIM NAM$(TEAMS%)
210 DIM GAM%(TEAMS%)
220 DIM PINS(TEAMS%)
230 DIM AVG%(TEAMS%)
240 DIM HIG%(TEAMS%)
250 DIM HIS%(TEAMS%)
260 DIM PTSW(TEAMS%)
270 DIM PTSL(TEAMS%)
280 INPUT "ENTER LEAGUE YEAR FOR TITLE LINE:",IYEARCON$
290 LPRINT SPC(30);NAM$
300 LPRINT SPC(34);IYEARCON$
310 LPRINT " "
320 PRINT "PRINTING BOWLER RECAP"
330 LPRINT "TEAM NAME                            PINS GMS  AVG  HIG  HIS 200 500 600 IMPR"
340 LPRINT "---- -----                           ---- ---  ---  ---  --- --- --- --- ----"
350 FOR T% = 1 TO TEAMS%
360 GET #1, (T% + 1)
370 TM%(T%) = CVI(TM$)
380 NAM$(T%) = NAM$
390 GAM%(T%) = CVI(GAM$)
400 PINS(T%) = CVS(PINS$)
410 AVG%(T%) = CVI(AVG$)
420 HIG%(T%) = CVI(HIG$)
430 HIS%(T%) = CVI(HIS$)
440 PTSW(T%) = CVS(PTSW$)
450 PTSL(T%) = CVS(PTSL$)
460 BID%(1) = CVI(B1ID$)
470 BID%(2) = CVI(B2ID$)
480 BID%(3) = CVI(B3ID$)
490 BID%(4) = CVI(B4ID$)
500 BID%(5) = CVI(B5ID$)
510 FOR B% = 1 TO BOWLERS%
520 GET #2,BID%(B%)
530 IF B% = 1 THEN LPRINT USING " ##  ";T%;
540 IF B% > 1 THEN LPRINT "     ";
550 LPRINT BNAM$;
560 LPRINT USING " ##### ";CVS(BPINS$);
570 LPRINT USING "### ";CVI(BGAM$);
580 LPRINT USING " ### ";CVI(BAVG$),CVI(BHIG$),CVI(BHIS$);
590 GAM2% = CVI(GAM2$): SER5% = CVI(SER5$): SER6% = CVI(SER6$)
600 IF GAM2% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(GAM2$);
610 IF SER5% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(SER5$);
620 IF SER6% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(SER6$);
630 DIFF% = CVI(BAVG$) - CVI(AVGLSTYR$)
640 LPRINT USING " ###";DIFF%
650 NEXT B%
660 NEXT T%
670 LPRINT "*****************************************************************************"
680 PRINT "PRINTING SUBSTITUTE RECAP"
690 LPRINT "SUBS"
700 FOR S% = 1 TO (NEXTID% - 1)
710 GET #2,S%
720 IF CVI(BTM$) > 0 GOTO 840
730 LPRINT SPC(5)
740 LPRINT BNAM$;
750 LPRINT USING " ##### ";CVS(BPINS$);
760 LPRINT USING "### ";CVI(BGAM$);
770 LPRINT USING " ### ";CVI(BAVG$),CVI(BHIG$),CVI(BHIS$);
780 GAM2% = CVI(GAM2$): SER5% = CVI(SER5$): SER6% = CVI(SER6$)
790 IF GAM2% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(GAM2$);
800 IF SER5% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(SER5$);
810 IF SER6% = 0 THEN LPRINT SPC(4) ELSE LPRINT USING "### ";CVI(SER6$);
820 DIFF% = CVI(BAVG$) - CVI(AVGLSTYR$)
830 LPRINT USING " ###";DIFF%
840 NEXT S%
850 LPRINT CHR$(12)     'SKIP TO NEXT PAGE
860 REM SORT TEAMS BY POINTS WON
870 PRINT "SORTING TEAMS BY POINTS WON"
880 DIM TABTM%(TEAMS%)
890 DIM TABPTS#(TEAMS%)
900 FOR S% = 1 TO TEAMS%
910 TABPTS#(S%) = 999999999#
920 NEXT S%
930 X% = 1: Y% = 1
940 PTSWT# = (PTSW(X%) * 1000000! + PINS(X%))
950 IF PTSWT# < TABPTS#(Y%) GOTO 970
960 Y% = Y% + 1: GOTO 940
970 LAST% = TEAMS%
980 TABPTS#(LAST%) = TABPTS#(LAST% - 1): TABTM%(LAST%) = TABTM%(LAST% - 1)
990 LAST% = LAST% - 1
1000 IF LAST% = Y% GOTO 1010 ELSE GOTO 980
1010 TABPTS#(Y%) = PTSWT#:TABTM%(Y%) = TM%(X%)
1020 IF X% = TEAMS% GOTO 1050
1030 Y% = 1: X% = X% + 1: GOTO 940
1040 REM END OF INTERNAL SORT ROUTINE
1050 PRINT "PRINTING TEAM STANDINGS"
1060 LPRINT SPC(30);"FINAL TEAM STANDINGS"
1070 LPRINT SPC(30);"--------------------"
1080 LPRINT " "
1090 LPRINT "PLACE TEAM                            WON   LOST   PINS   GAM  AVG  HIG  HIS"
1100 LPRINT "----- -----                           ---   ----   ----   ---  ---  ---  ---"
1110 PLACE% = 1
1120 FOR PL% = TEAMS% TO 1 STEP -1
1130 T% = TABTM%(PL%)
1140 LPRINT USING "  ##  ";PLACE%;
1150 LPRINT NAM$(T%);
1160 LPRINT USING "###.#  ";PTSW(T%),PTSL(T%);
1170 LPRINT USING "#####  ";PINS(T%);
1180 LPRINT USING " ### ";GAM%(T%);
1190 LPRINT USING "#### ";AVG%(T%),HIG%(T%),HIS%(T%)
1200 PLACE% = PLACE% + 1
1210 NEXT PL%
1220 LPRINT "*****************************************************************************"
1230 PRINT "Processing Completed - Returning to MENU"
1240 CLOSE
1250 RUN "A:MENU"