3
Applications and Education
Standings
Dan and Philip Seyer
"Standings" is a program for sports fans who would like to create their own standings statistics. It was written by a 12-year-old and his father.

This program will enable you to create professional-looking team standing statistics. We developed the program with baseball in mind, but you can use it for any sport. You might een adapt it for other purposes. (For example, a manager or supervisor might use it to keep track of employee performance.)

Input in Graphics Mode 2 + 16

Once you type in the program and get it working, you'll see a colorful menu in Graphics mode 2. After you type A, you will be prompted to enter the date, the name of the sport, the number of teams, the team names, and win-loss records. A special routine at lines 420 to 499 allows you to enter this data in Graphics Mode 2. Normally, you can't enter data in this mode without using a text window and an INPUT statement.

Output Data

After you enter the data mentioned above, the program does the rest. It calculates each team's percentage and GB statistic (GB stands for games behind the leader.) Then the program sorts the teams into proper order according to winning percentages.

If you hold down the OPTION key when you select choice B, the program will play some random sounds as it prints the sport caption at the top of the screen. if you get tired of hearing the sounds, just press B without holding down the OPTION key. Then the program will skip over the random sound-generation routine.

Updating Statistics

Statistics are easily updated. To do this, select option B from the main menu. You can then change a team's win-loss record by pressing W to add a win or L to add a loss. The team's percentage changes instantly when you change the wins or losses. You can also change the spelling of a team's name, delete an entire team record, or add a new team. The program prompts you step by step for the appropriate entries and then modifies or deletes the appropriate DATA statements. The program will automatically re-sort the teams into proper order after you have updated all the win-loss statistics.

Resaving the Program

After updating the statistics, be sure to end the program by selecting the END option from the main menu. The program will then ask you whether you have a program recorder or disk drive. You can answer by typing P for program recorder or D for disk drive.

Program recorder. If you have a program recorder, you will be asked to position the tape for saving the program. When you press RETURN, your program will be saved.

Disk drive. If you have a disk drive, the program and any new data will automatically be resaved to disk when you type D and press RETURN.

Printout

To get a printout of your favorite league's standings, just type C for your menu choice. You will then be prompted to turn on your printer. (You may also want to adjust your paper at this time.) Then press RETURN to start the printing.

       STATS ENTERED   08-28-83

       HOMETOWN LEAGUE STANDINGS

   TEAMS           W   L   PCT.  GB

1  TIGERS          17  0  1.000  --
2  BEARS           9   8   .529  8
3  PADRES          9   9   .500  8  1/2
4  A'S             9   10  .474  9
5  RAMS            8   11  .421  10
6  LIONS           7   10  .412  10
7  SENATORS        6   11  .353  11
8  WHITE SOX       4   15  .211  14
Sort Routine

The teams will be listed in order by percentage from highest to lowest. A sort routine at line 900 to 972 does this for you automatically. Also notice the GB statistics, games behind the leader. The GB statistic is the number of times, a team must beat the first place team to move into a tie for first place.

Self-Modifying Code

An interesting feature of the program is that it is self-modifying. When you enter information, the program creates DATA statements for you and saves the information in those DATA statements. (See lines 400 to 420.) This way, you don't need a separate data file since the data is saved along with your program.

The program as printed here contains the data for the eight teams listed in the sample printout. The sample data are included only to get you started. It is suggested that you practice with this data and experiment with the program. Then delete each of the eight teams and enter your own information.


Standings
0 ? "INITIALIZING......"
1 READ Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10:SAV=Q1
2 READ Q12,Q13,Q14,Q15,Q17,Q18,Q20,Q21,Q22,Q24,Q26,Q27,Q30,Q33,Q34,Q35,Q40,Q64,Q65,Q68,Q70
3 READ Q72,Q74,Q82,Q89,Q95,Q97,Q100,Q125,Q126,Q128,Q155,Q165,Q190,Q246,Q255,Q260,Q261,Q286,Q289,Q300,Q304,Q306
4 READ Q400,Q425,Q430,Q500,Q507,Q511,Q533,Q559,Q578,Q630,Q694,Q705,Q752,Q760,Q764,Q765,Q770,Q800,Q842,Q871,Q895
5 READ Q898,Q900,Q975:GOTO 450
6 DATA 1,2,3,4,5,6,7,8,9,10,12,13,14,15,17,18,20,21,22,24,26,27,30,33,34,35,40,64,65,68,70
7 DATA 72,74,82,89,95,97,100,125,126,128,155,165,190,246,255,260,261,286,289,300,304,306
8 DATA 400,425,430,500,507,511,533,559,578,630,694,705,752,760,764,765,770,800,842,871,895,898,900,975
13 RESTORE Q300:READ L,TEMP$:RETURN :REM GETS SPORT NAME
14 TEMP1$="{14 SPACES}":RETURN 
15 GOSUB Q22:POSITION X,Y:IF Y$="%" THEN ? " ":GOTO Q17:REM INPUTS LETTER TYPED
16 ? #6;"*"
17 POSITION X,Y:GOSUB Q21:GET #Q1,A:RETURN 
18 TEMP$="{15 SPACES}":RETURN 
19 ? "{38 SPACES}";:RETURN 
21 POKE Q764,Q255:RETURN :REM CLEARS KEY PRESSED REGISTER
22 CLOSE #Q1:OPEN #Q1,Q4,Q18,"K:":POKE Q752,Q1:RETURN :REM OPEN KEYBOARD FOR INPUT
24 II=INT(RND(Q0)*Q24):FOR A=Q12 TO Q0 STEP -Q1:SOUND Q0,II,Q2,A:NEXT A:RETURN :REM MAKES RANDOM SOUND
25 IF START=Q0 THEN RETURN :REM DELETES CHAR. FROM TEMP$
26 POSITION X,Y:IF Y$="%" THEN ? " "
27 IF Y$<>"%" THEN ? #6;" "
28 X=X-1:TRAP 31:TEMP$=TEMP$(Q1,START-Q1):START=START-Q1:RETURN 
29 GOSUB Q22:GET #1,A:RETURN 
31 START=Q0:X=XX:GOSUB Q18:RETURN 
32 LL=ORDER(OL):RETURN 
33 FOR D=YY+Q6 TO YY+Q13:POSITION Q1,D:GOSUB 19:NEXT D:POKE Q752,Q1:RETURN :REM CLEARS STAT MENU
35 POKE 559,0:FOR LNO=START TO LL STEP STEP:? CHR$(125):REM LINE DELETION
36 RESTORE LNO:READ Y$:IF Y$="{ESC}" THEN RETURN 
37 ? "{DOWN}";LNO:? :? :? "CONT":POSITION Q0,Q0:POKE Q842,Q13:STOP 
38 POKE Q842,Q12:? CHR$(125):NEXT LNO:POKE 559,34:RETURN 
39 GOSUB Q289:GOTO Q533
41 TEMP1$="Y":GOSUB Q705:GOSUB 32:REM TEAM DELETION
42 RESTORE LL:READ LNO,TEMP$:GOSUB Q33:POSITION Q6,YY+Q8
43 ? "TYPE Y TO DELETE ";TEMP$:POSITION Q6,YY+Q10:? "HIT RETURN TO GO BACK TO MENU":GOSUB Q22:GET #Q1,A
44 IF A<>89 THEN RETURN 
45 GOSUB Q260:TEAMNO=TEAMNO-Q1:LNO=Q304:TEMP1$=STR$(TEAMNO):GOSUB Q898:GOSUB Q400
46 START=LL:STEP=Q2:GOSUB Q35:IF TEAMNO=Q0 THEN GOTO Q507
47 GOSUB Q260:GOSUB Q975:GOSUB Q900:GOTO Q507
52 GRAPHICS Q18:GOSUB Q190:GOSUB Q24:POSITION Q3,Q3:? #6;"turn on printer ":REM OUTPUT ROUTINE
53 ? #Q6:? #Q6:? #Q6;"{3 SPACES}HIT P TO PRINT":GOSUB Q22:GOSUB Q97:? #Q6
54 ? #Q6;"HIT RETURN FOR MENU":GOSUB Q22:GOTO 755
55 GOSUB Q97:RESTORE Q895:READ LNO,TEMP$:TRAP 750:LPRINT :LINE$(Q10,Q24)="STATS ENTERED":X=LEN(TEMP$)
56 LINE$(Q26,LEN(TEMP$)+Q26)=TEMP$:LPRINT LINE$:GOSUB Q97:RESTORE 300:READ L,TEMP$:X=(40-(LEN(TEMP$)+10))/2
57 LINE$(X,X+LEN(TEMP$))=TEMP$:LINE$(X+LEN(TEMP$),40)=" STANDINGS"
58 LPRINT :LPRINT :LPRINT :LPRINT LINE$:RESTORE Q871:READ L,L
59 RESTORE L:READ L,TEMP$,W,L:LPRINT :LPRINT "{3 SPACES}TEAMS{11 SPACES}W{3 SPACES}L{3 SPACES}PCT.  GB":Y=Q0:GOSUB Q260:LPRINT 
60 GOSUB Q97:FOR I=Q1 TO TEAMNO:Y$=")":RESTORE ORDER(I):READ LNO,TEMP1$,LW,LL:LINE$(Q1,LEN(STR$(I)))=STR$(I)
61 LINE$(Q4,Q18)=TEMP1$:LINE$(Q20,Q20+LEN(STR$(LW)))=STR$(LW):LINE$(Q24,Q24+(LEN(STR$(LL))))=STR$(LL)
62 GOSUB Q261:LINE$(Q27,Q33)=TEMP$(Q1,Q5):LINE$(34,Q40)=TEMP1$:LPRINT LINE$:GOSUB Q97:NEXT I:RETURN 
70 GOSUB Q260:IF TEAMNO>=Q30 THEN GOTO Q760:REM ADDS TEAM
71 GRAPHICS Q18:GOSUB Q190:POSITION Q1,Q2:? #6;"enter name of team":Y$="'":GOSUB Q578:LNO=Q306
72 RESTORE LNO:READ TEMP$:IF TEMP$<>STR$(LNO) THEN GOSUB Q898:GOSUB Q400:ORDER(TEAMNO+Q1)=LNO:GOTO 74
73 LNO=LNO+Q2:GOTO Q72
74 TEAMNO=TEAMNO+Q1:TEMP1$=STR$(TEAMNO):LNO=Q304:GOSUB Q400:GOSUB Q900:GOTO Q507
95 FOR I=1 TO 500:NEXT I:RETURN 
97 LINE$="{38 SPACES}":RETURN 
99 FOR D=Q6 TO Q22:POSITION Q1,D:GOSUB 19:NEXT D:RETURN 
100 GRAPHICS Q18:GOSUB Q190:GOSUB Q22:POSITION Q0,Q4:? #Q6;"YOU MUST ENTER TEAMSBEFORE USING : OR C."
105 GOSUB Q95:GOTO Q507:REM GIVES MESSAGE
155 POKE Q82,Q2:POSITION Q2,YY+Q7:IF I<TEAMNO THEN ? "A DISPLAY NEXT GROUP OF TEAMS{7 SPACES}":REM STAT MENU
157 ? "B ADD OR SUBTRACT WINS OR LOSSES{4 SPACES}":? "C RETURN TO MENU{20 SPACES}"
160 ? "D CORRECTION OF TEAM NAME{11 SPACES}":? "E END{31 SPACES}"
161 ? "F DELETE TEAM{23 SPACES}"
165 POKE Q764,Q255:GOSUB Q22:GET #Q1,A:IF A>Q64 OR A<Q72 THEN CLOSE #Q1:RETURN 
170 GOTO Q165
190 POSITION Q5,Q0:? #6;"StAnDiNgS":GOSUB Q24:RETURN 
199 REM DRAWS TITLE BOX
200 ? :POKE Q752,Q1:GOSUB Q13:L=LEN(TEMP$):LL=Q40-(STNO+L):LL=LL/Q2:POSITION LL,Q1:FOR I=Q1 TO L+STNO
205 ? "{N}";:NEXT I:? "{DOWN}{LEFT}{B}":POSITION LL,Q2:? "{V}":POSITION LL,Q3:FOR I=Q1 TO L+STNO:? "{M}";:NEXT I:RETURN 
210 ? " ";:FOR J=Q1 TO LEN(TEMP$):? TEMP$(J,J);:GOSUB Q24:NEXT J:RETURN 
215 POSITION LL+Q1,Q2:FOR J=Q1 TO LEN(TEMP$):? TEMP$(J,J);:GOSUB Q24:NEXT J:RETURN 
255 TEMP1$=TEMP$(Q1,START):RETURN 
260 RESTORE Q304:READ LNO,TEAMNO:RETURN :REM PUTS NUMBER OF TEAMS INTO TEAMNO
261 IF LW=Q0 AND LL=Q0 THEN PCT1=Q0:GOTO 263:REM CALCULATES GB & PCT & PRINTS THEN
262 GOSUB Q14:GOSUB Q18:PCT1=(LW/(LW+LL)):PCT1=(PCT1+5E-04)
263 TEMP$(Q1,Q5)=STR$(PCT1):IF LW=Q0 THEN TEMP$=" .000"
264 IF TEMP$(Q1,Q1)="0" THEN TEMP$(Q1,Q1)=" "
265 IF TEMP$(Q3,Q3)=" " THEN TEMP$(Q3,Q3)="0"
266 IF TEMP$(Q4,Q4)=" " THEN TEMP$(Q4,Q4)="0"
267 IF TEMP$(Q5,Q5)=" " THEN TEMP$(Q5,Q5)="0"
268 IF TEMP$(Q2,Q2)=" " THEN TEMP$(Q2,Q2)="."
269 GB=(((W-L)/Q2)-(LW-LL)/Q2):IF L=Q0 THEN GB=W/Q2-(LW-LL)/Q2
270 IF GB<=Q0 THEN TEMP1$="--":GOTO Q286
271 TEMP1$=STR$(GB):FOR J=Q1 TO LEN(STR$(GB)):IF TEMP1$(J,J)<>"." THEN NEXT J:GOTO Q286
272 TEMP1$(J,J)=" ":TEMP1$(Q3,Q6)=" 1/2"
273 IF TEMP1$(Q1,Q1)="0" THEN TEMP1$(Q1,Q1)=" "
286 IF Y$=")" THEN RETURN 
287 POSITION Q26,Y+Q5:? TEMP$(Q1,Q5):IF Y$<>"<" THEN POSITION Q33,Y+Q5:? TEMP1$
288 RETURN 
289 POSITION Q3,Q8:? #6;"{3 SPACES}":RETURN 
290 GOSUB Q289:POSITION Q0,Q10:? #6;"{3 SPACES}too many teams{4 SPACES}":GOTO Q533
292 POSITION Q0,Y:? #Q6;"NUMBERS ONLY, PLEASE":IF Y=Q8 THEN GOSUB Q770:GOTO 605
293 GOSUB Q765:GOTO 610
298 RESTORE ORDER(OL):READ LNO,TEMP1$,LW,LL:RETURN 
299 REM NAME OF SPORT
300 DATA 300,HOMETOWN LEAGUE,0
302 DATA STANDINGS
303 REM NO. OF TEAMS
304 DATA 304,8,4,312
305 REM TEAM DATA 
306 DATA 306,LIONS{9 SPACES},7,10
308 DATA 308,A'S{11 SPACES},9,10
310 DATA 310,BEARS{9 SPACES},9,8
314 DATA 314,RAMS{10 SPACES},8,11
316 DATA 316,TIGERS,17,0
318 DATA 318,PADRES{8 SPACES},9,9
320 DATA 320,WHITE SOX{5 SPACES},4,15
322 DATA 322,SENATORS,6,11
399 DATA {ESC},0,0
400 GRAPHICS Q0:POKE Q559,Q0:SETCOLOR Q1,Q9,Q4:? CHR$(Q125):REM CREATES DATA LINES
410 ? "{DOWN}";LNO;" DATA ";LNO;",";TEMP1$;",";LW;",";LL:? :? :? "CONT"
415 POSITION Q0,Q0:POKE Q842,Q13:STOP 
420 POKE Q842,Q12:SETCOLOR Q1,Q9,Q10:Y$="":RETURN 
425 W=Q0:START=Q0:XX=X:GOSUB Q18:POKE Q752,Q1:REM INPUT IN GR. MODE 2+16
430 GOSUB Q15:IF A=Q155 THEN GOTO 446
435 IF A=126 THEN GOSUB 25:GOTO Q430
440 IF START=PROP THEN GOTO Q430
441 IF W=Q1 THEN GOTO 445
442 IF LINE$="IN" AND A=Q427 THEN W=Q1:POKE Q694,Q128:GOTO Q430
443 IF LINE$<>"LINE" THEN POKE Q694,Q0
444 IF Y$="%" THEN ? CHR$(A):X=X+Q1:POSITION X,Y:START=START+Q1:TEMP$(START,START+Q1)=CHR$(A):GOTO Q430
445 ? #Q6;CHR$(A):X=X+Q1:POSITION X,Y:START=START+Q1:TEMP$(START,START+Q1)=CHR$(A):GOTO Q430
446 IF Y$<>"%" THEN POSITION X,Y:? #6;" ":GOTO 448
447 POSITION X,Y:? " "
448 IF START=Q0 THEN GOSUB Q18
449 POKE Q694,Q0:RETURN 
450 DIM TEMP1$(Q14),TEMP$(Q15),Y$(Q1),ORDER(Q30),LINE$(Q40),V$(1)
455 RESTORE Q800:READ Y$:IF Y$<>"{ESC}" THEN GOSUB Q260:RESTORE Q800:FOR I=Q1 TO TEAMNO:READ W,W,L,L:ORDER(I)=W:NEXT I
500 REM MAIN MENU
507 V$="":XX=Q0:GRAPHICS Q18:GOSUB Q190:? #Q6:? #Q6;"A enter new teams":GOSUB Q24:? #Q6;"B look at standings"
508 START=1:GOSUB Q24:? #Q6;"C printout standings";:GOSUB Q24
509 ? #Q6;"D add team":GOSUB Q24:? #Q6;"E end":GOSUB Q24:? #Q6
510 GOSUB Q260:? #Q6;" you have entered ";TEAMNO:POSITION Q1,Q9:? #Q6;"teams."
511 POKE Q764,Q255:GOSUB Q22:GET #Q1,A:IF A<Q64 OR A>Q70 THEN GOTO 511
514 IF A=69 THEN GOSUB 1000:GOTO Q507
515 IF A=Q65 THEN GOTO 526
516 IF A=Q68 THEN GOTO Q70
517 RESTORE Q306:READ TEMP$:IF TEMP$(Q1,Q1)="{ESC}" THEN GOTO Q100
519 IF A=66 THEN SAV=Q1:GOSUB Q630:GOTO Q507
520 IF A=67 THEN GOSUB 52:GOTO Q507
522 GOTO Q511
523 REM ENTER TEAMS
526 GOSUB 875:LL=Q0:LW=Q0:GRAPHICS Q18:GOSUB Q190:POSITION Q1,Q3:? #Q6;"enter name of sport"
527 LINE$="LINE":POKE Q694,Q128:X=Q3:Y=Q4:PROP=Q14:GOSUB Q425:TRAP 527:TEMP1$=TEMP$(Q1,START)
530 GOSUB Q255:POSITION Q1,Q7:? #Q6;"enter no. of teams"
533 X=Q3:Y=Q8:PROP=Q2:GOSUB Q425:TRAP 39:TEAMNO=VAL(TEMP$):IF TEAMNO>Q30 OR TEAMNO<1 THEN GOSUB 289:GOTO 533
535 LNO=Q300:GOSUB Q400:TEMP1$=TEMP$(Q1,START)
536 LNO=Q304:GOSUB Q400:START=Q306:LL=398:STEP=Q2:GOSUB Q35:GOSUB Q14
575 LNO=Q304:FOR I=Q1 TO TEAMNO:LNO=LNO+Q2:GRAPHICS Q18:POKE 559,Q34:GOSUB 190:POSITION Q1,Q2
576 ? #Q6;"enter team no. #";I
578 LINE$="IN":Y=Q3:X=Q3:PROP=Q14:GOSUB Q425
580 TEMP1$=TEMP$:IF START=Q0 THEN GOTO Q578
605 POSITION Q0,Q5:? #Q6;" enter no. of wins":GOSUB Q24
606 X=Q3:Y=Q6:POSITION X,Y:PROP=Q3:GOSUB Q425:Y=Q8:TRAP Q770:LW=VAL(TEMP$):IF LW<Q0 OR LW>999 THEN GOTO Q770
610 POSITION Q0,Q8:? #Q6;" ENTER NO. OF LOSSES":GOSUB Q24
613 X=Q3:Y=Q9:POSITION X,Y:GOSUB Q425:Y=Q10:TRAP Q765:LL=VAL(TEMP$):IF LL<Q0 OR LL>999 THEN GOTO Q765
614 IF Y$="'" THEN RETURN 
615 POKE 702,Q64:GOSUB Q400:NEXT I:GOSUB Q898:GOSUB Q975:GOSUB Q900:GOTO Q507
629 REM PRINTS STANDINGS IN GR. MODE 0
630 Y$="":PCT1=Q0:RESTORE Q895:READ LNO,TEMP$:POKE 82,(40-(LEN(TEMP$)+14))/2:GOSUB 790:? "STATS ENTERED ";TEMP$
631 STNO=Q12:IF PEEK(53279)<>Q3 OR V$="Y" THEN GOSUB 200:POSITION LL+Q1,Q2:? TEMP$;" STANDINGS":PCT1=1
632 IF V$="Y" THEN Y$="<"
635 IF PCT1=1 THEN GOSUB Q24:GOTO 650
640 GOSUB 200:GOSUB 215:RESTORE 302:READ TEMP$:GOSUB 210
650 RESTORE Q871:READ L,L:RESTORE L:READ LNO,TEMP$,W,L:POSITION Q0,Q5:? "{4 SPACES}TEAMS{10 SPACES}W{3 SPACES}L{3 SPACES}PCT.  GB{5 SPACES}"
654 IF V$<>"Y" THEN START=1
655 Y=Q0:GOSUB Q260:FOR I=START TO TEAMNO:RESTORE ORDER(I):READ LNO
659 Y=Y+Q1:POSITION Q1,Y+Q5:? I
660 POSITION Q4,Y+Q5:READ TEMP$:? TEMP$:READ LW:POSITION 19,Y+Q5:? LW:READ LL
661 POSITION 23,Y+Q5:? LL:GOSUB Q261
676 IF I>24 THEN TEMP2=Q4:GOTO 680
677 IF I>16 THEN TEMP2=Q3:GOTO 680
678 IF I<Q9 THEN TEMP2=Q1:GOTO 680
679 TEMP2=Q2
680 IF I<>Q8 AND I<>16 AND I<>Q24 THEN NEXT I
681 YY=Y:IF V$="Y" THEN 705
682 GOSUB Q155
695 GOSUB 1000:IF A=66 THEN GOTO Q705
696 IF A=Q65 AND I<TEAMNO THEN GOSUB 99:Y=Q0:NEXT I
697 IF A=67 THEN RETURN 
698 IF A=Q70 THEN GOTO 41
699 IF A=Q68 THEN 727
700 GOSUB Q165:GOTO 695
705 GOSUB Q33:Y$="%":POSITION Q6,YY+Q7:? "ENTER TEAM  NO. THEN HIT RETURN":PROP=Q2:X=Q17:Y=YY+Q8:POKE Q752,Q1
706 TRAP Q705:GOSUB Q425:GOSUB Q33:OL=VAL(TEMP$):IF OL>TEAMNO THEN GOTO Q705
707 IF TEMP2=Q3 THEN IF OL<Q17 OR OL>Q24 THEN GOTO Q705
708 IF TEMP2=Q2 THEN IF OL<Q9 OR OL>16 THEN GOTO Q705
709 IF TEMP3=Q1 THEN IF OL>Q8 OR OL<Q1 THEN GOTO Q705
710 IF TEMP2=4 THEN IF OL>30 OR OL<25 THEN GOTO Q705
711 IF TEMP1$="Y" THEN RETURN 
712 POKE Q82,Q2:POSITION Q2,YY+Q7:? "PRESS W TO ADD WIN":? "PRESS L TO ADD LOSS":? "PRESS S";:REM WIN LOSS CHANGE
713 ? " THEN W TO SUBTRACT WIN":? "PRESS S THEN L TO SUBTRACT LOSS":? "PRESS M FOR MENU":? "PRESS RETURN TO ";
714 ? "CHANGE ANOTHER TEAMS{8 SPACES}STATS":GOSUB 298:STEP=OL:FOR I=1 TO YY:POSITION 33,I+5:? "{6 SPACES}";:NEXT I
715 IF OL>Q8 THEN OL=OL-Q8:GOTO 715
716 GOSUB 29:IF A<>Q155 AND A<>83 AND A<>77 AND A<>76 AND A<>87 THEN 716
717 GOTO 985:GOSUB 29:GOTO 720
718 IF A=87 THEN LW=LW-Q1:GOTO 723
719 IF A=76 THEN LL=LL-Q1:GOTO 723
720 IF A=76 THEN LL=LL+Q1
721 IF A=87 THEN LW=LW+Q1
722 IF A=77 THEN GOSUB Q33:POSITION Q8,D-Q2:GOSUB 19:GOSUB 997:OL=STEP:GOSUB Q400:GOSUB Q898:GOSUB Q900:RETURN 
723 IF LL<Q0 THEN LL=Q0
724 IF LW<Q0 THEN LW=Q0
725 POSITION 19,OL+Q5:? LW;" ":POSITION 23,OL+Q5:? LL;" ":GOSUB Q21:Y=OL:Y$="<":GOSUB Q261:GOTO 716
726 REM CHANGES TEAM NAME
727 TEMP1$="Y":GOSUB Q705:POSITION Q6,YY+Q7:? "ENTER NEW NAME FOR TEAM #";OL:X=Q13:Y=YY+Q8:PROP=Q14
728 LINE$="IN":Y$="%":GOSUB Q425:TEMP1$=TEMP$:RESTORE ORDER(OL):READ TEMP$,TEMP$,LW,LL:LNO=ORDER(OL):GOSUB Q400
729 RETURN 
730 IF A<>Q155 THEN Y=OL:GOSUB 272:GOTO 715
735 GOSUB Q33:POSITION Q0,YY+Q6:GOTO 681
750 TRAP 750:POSITION Q0,Q3:? #Q6;"  turn on printer!":? #Q6:? #Q6;"{4 SPACES}then hit p.":POSITION Q0,Q6
755 ? #6;"{18 SPACES}":GOSUB Q22:GET #Q1,A:IF A<>80 THEN RETURN 
756 GOTO 55
760 POSITION Q0,Q8:? #6;"sorry,  you have{4 SPACES}already entered the maximum no. of teams":GOTO Q511
765 POSITION Q3,Q9:? #6;"{3 SPACES}":GOTO 613
767 GOTO 56
770 POSITION Q3,Q6:? #6;"{3 SPACES}":GOTO 606
775 ? :? "  SEE ERROR - ";PEEK(195):POKE Q752,Q0:END 
790 GRAPHICS Q0:SETCOLOR Q2,Q12,Q4:SETCOLOR Q4,Q3,Q6:RETURN 
799 REM DATA FOR THE ORDER OF TEAMS
800 DATA 800,316,4,860
802 DATA 802,310,4,860
804 DATA 804,318,4,860
806 DATA 806,308,4,860
808 DATA 808,314,4,860
810 DATA 810,306,4,860
812 DATA 812,322,4,860
814 DATA 814,320,4,860
871 DATA 871,316,4,860
875 GRAPHICS Q18:GOSUB Q190:POSITION Q0,Q2:? #Q6;"{4 SPACES}enter date":? #6;" EXAMPLE : 12/15/83"
880 ? #Q6;"{14 SPACES}OR":? #6;"{11 SPACES}DEC. 15"
885 LINE$="LINE":POKE Q694,Q128
890 X=Q6:Y=Q6:PROP=Q8:GOSUB Q425:LNO=Q895:TRAP 885:GOSUB Q255:GOSUB Q400:RETURN 
895 DATA 895,06-30-83,9,10
898 GRAPHICS Q18:? #Q6:? #Q6:? #Q6;"  sorting teams.":? #Q6
899 ? #6;"{5 SPACES}PLEASE WAIT.":GOSUB Q95:RETURN 
900 RESTORE ORDER(Q1):READ L,TEMP$,START,PROP:TEAM=ORDER(Q1):START=START-PROP:GOSUB Q260:REM SORT ROUTINE
901 IF TEAMNO=Q0 THEN RETURN 
902 FOR I=Q1 TO TEAMNO-Q1:REM SORT ROUTINE
903 FOR J=I+Q1 TO TEAMNO
910 RESTORE ORDER(I):READ LNO,TEMP$,W,L
915 IF W=Q0 THEN PCT1=Q0:GOTO 925
920 PCT1=(W/(W+L))
925 RESTORE ORDER(J):READ LNO,TEMP$,LW,LL
927 IF LW=Q0 THEN PCT2=Q0:GOTO 940
930 PCT2=(LW/(LW+LL))
940 IF LW-LL>START THEN TEAM=ORDER(J):START=LW-LL
945 IF PCT2=PCT1 AND W<LW THEN GOSUB 980:GOTO 971
950 IF PCT2>PCT1 THEN GOSUB 980
971 NEXT J:NEXT I
972 STEP=Q2:START=Q800:LL=860:GOSUB Q35:GOSUB Q260:LNO=798:REM STORES ORDER DATA
973 FOR I=Q1 TO TEAMNO:LNO=LNO+Q2:TEMP1$=STR$(ORDER(I)):GOSUB Q400:NEXT I:GOSUB Q260:TEMP1$=STR$(TEAM)
974 LNO=871:GOSUB 400:RETURN 
975 POKE Q559,Q0:RESTORE Q306:FOR I=Q1 TO TEAMNO
976 READ LNO,TEMP1$,LW,LL:ORDER(I)=LNO:NEXT I
977 RETURN 
980 PROP=ORDER(I):ORDER(I)=ORDER(J):ORDER(J)=PROP:RETURN 
985 IF A=Q155 THEN 2000
990 IF A<>83 THEN 720
991 IF A=83 THEN POKE 764,255:GET #1,A:GOTO 718
995 GET #1,A:GOTO 717
997 POSITION Q6,YY+Q7:? "ENTER DATE THEN HIT RETURN":PROP=Q8:Y$="%":X=16:Y=YY+Q8:POKE Q752,Q1:LINE$="LINE"
998 POKE Q694,Q128:RESTORE ORDER(OL):READ LNO,TEMP1$:GOSUB Q425:LNO=ORDER(OL):GOSUB Q400:GOSUB Q255:LNO=Q895
999 RETURN 
1000 POKE 82,2:IF A<>69 THEN RETURN 
1005 GOSUB 790:? "DO YOU HAVE A DISK DRIVE OR A PROGRAM RECORDER ?":? :? "{8 SPACES}(HIT RETURN FOR MENU)"
1010 POSITION 16,5:INPUT TEMP$:TRAP Q507
1015 IF TEMP$(Q1,Q1)="D" OR TEMP$(Q1,Q1)="D" THEN 1050
1020 ? :? "{7 SPACES}HIT RETURN TO SAVE"
1025 CSAVE :END 
1050 ? :? "{9 SPACES}HIT RETURN TO SAVE":GOSUB Q22
1055 GET #Q1,A:IF A<>155 THEN 1055
1060 TRAP 775:SAVE "D:STANDING.SAV":POKE 752,0:END 
2000 OL=STEP:RESTORE ORDER(OL):READ LNO,TEMP1$:LNO=ORDER(OL):GOSUB Q400:V$="Y"
2004 REM PICK TEAMS TO CHANGE STATS ON
2005 POKE 752,2:GRAPHICS 0:? :? :? "  PICK GROUP OF TEAMS TO DISPLAY":? :? 
2006 ? "{8 SPACES}1) TEAMS 1-8"
2007 ? "{8 SPACES}2) TEAMS 9-16"
2008 ? "{8 SPACES}3) TEAMS 17-24"
2009 ? "{8 SPACES}4) TEAMS 25-32":? :? :? 
2010 TRAP 2010:? "{UP}{5 SPACES}YOUR CHOICE:{4 SPACES}{3 LEFT}";:INPUT CHOICE:IF CHOICE<1 OR CHOICE>4 THEN 2010
2015 GOSUB CHOICE+3000:IF START>TEAMNO THEN 2010
2016 V$="Y":GOTO 630
3001 START=1:RETURN 
3002 START=9:RETURN 
3003 START=17:RETURN 
3004 START=25:RETURN 
Yes, line 165 has a logic error. According to the logic:
IF A>Q64 OR A<Q72 then ...
which is, of course, ALWAYS true for ANY value of A! The line should read:
165 POKE Q764,Q255:GOSUB Q22:GET #Q1,A:IF A>Q64 AND A<Q72 THEN CLOSE #Q1:RETURN
The line has not been fixed in the listing above or below, it is simply being pointed out.

Listing. Standings.
Download (Saved BASIC) / Download (Listed BASIC)


Return to Table of Contents | Previous Section | Next Section