here is the code for my program, all of those thick/dark rectangles are actually -->
i do not think that the code can be optimized much aside from a few for loops at the end
thank you for all the help
Code: **TI92P* main Program file 04/05/08, 11:16 R
tennis(a,b,c,d,e,f,g,h,i)
Prgm
newMat(9,8)tenn
Local a,b,c,d,e,f,g,h,i,z,aa,bb,cc,dd,ee,ff,gw,ttl,gg,hh,ii,jj,kk,ˆ,gl,fi,ft,player,ad
d,fe,ufe,af,as,st,si,ae,au,player1,player2,gw1,gl1,gw2,gl2,ag,fi1,fi2,ft2,ft1,si
1
,st2,si2,st1,y,chg,chng
0chg
0chng
0st1
0si2
0gl
0gw
0fi
0ft
0add
0fe
0ufe
0af
0as
0st
0si
0ae
0au
0gwd
0gld
0fi1
0fi2
0ft2
0ft1
0si1
0st2
Lbl err
PopUp {"1 Singles","2 Singles","3 Singles","1 Doubles","2 Doubles","3 Doubles"},match
If match=1 Then
1z
ElseIf match=2 Then
2z
ElseIf match=3 Then
3z
ElseIf match=4 Then
4z
ElseIf match=5 Then
5z
ElseIf match=6 Then
6z
Else
Goto err
EndIf
"1 Singles"aa
"2 Singles"bb
"3 Singles"cc
"1 Doubles"dd
"2 Doubles"ee
"3 Doubles"ff
"First Serves"gg
"Second Serves"hh
"Lets"ii
"Forced"jj
"Unforced"kk
This part defines the variables and sets up the titles
Code: 1ˆ
Loop
If ˆ=1 Then
Goto ttl
Else
EndIf
0add
0add1
0add2
0chg
this sends the loop to the lbl "ttl" near the end of the loop so that the string "Title" is assigned a value
the rest resets all of the drop down menus (kinda OCD about that)
the variable "z" is used to determine which title to output. the dialog boxes for the "singles" and "doubles" are different and are differentiated by the following if statement (see above for details)
Code: If zž1 and z<4 Then
Dialog
Title string(ttl)
DropDown "Match",{"1 Singles","2 Singles","3 Singles","1 Doubles","2 Doubles","3 Doubles"},z
Text ""
Text string(player)
Text ""
Text "Games Won: "&string(gw)&"-"&string(gl)
Text gg&": "&string(fi)&"/"&string(ft)
Text hh&": "&string(si)&"/"&string(st)
DropDown "Change",{"","Games",gg,hh,"Exit"},add
DropDown "Change Players",{"","Change","Cancel"},chg
EndDlog
This is the output of the program.
the following section looks at the choice in the drop down menu and has if then statements for all possible additions and subtractions of points
Code: If add=1 and chg=1 or add (not equal) 1 and chg (not equal) 1 then
Cycle
Else
If add=1 Then
Goto ttl
ElseIf add=2 Then
PopUp {"Win","Lost","Cancel","Minus Win","Minus Lost"},ag
If ag=1 Then
gw+1gw
gw-->tenn[z,2]
ElseIf ag=2 Then
gl+1gl
gl-->tenn[z,3]
ElseIf ag=3 Then
Cycle
ElseIf ag=4 Then
If gw=0 Then
Cycle
Else
gw-1gw
gw-->tenn[z,2]
EndIf
ElseIf ag=5 Then
If gl=0 Then
Cycle
Else
gl-1gl
gl-->tenn[z,3]
EndIf
EndIf
ElseIf add=3 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},af
If af=1 Then
ft+1ft
fi+1fi
ft-->tenn[z,5]
fi-->tenn[z,4]
ElseIf af=2 Then
ft+1ft
ft-->tenn[z,5]
ElseIf af=3 Then
Cycle
ElseIf af=4 Then
If ft=0 or fi=0 Then
Cycle
Else
ft-1ft
fi-1fi
ft-->tenn[z,5]
fi-->tenn[z,4]
EndIf
ElseIf af=5 Then
If ft=0 Then
Cycle
Else
ft-1ft
ft-->tenn[z,5]
EndIf
Else
EndIf
ElseIf add=4 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},as
If as=1 Then
st+1st
si+1si
sttenn[z,7]
si-->tenn[z,6]
ElseIf as=2 Then
st+1st
st-->tenn[z,7]
ElseIf as=3 Then
Cycle
ElseIf as=4 Then
If st=0 or si=0 Then
Cycle
Else
st-1st
si-1si
st-->tenn[z,7]
si-->tenn[z,6]
EndIf
ElseIf as=5 Then
If st=0 Then
Cycle
Else
st-1st
st-->tenn[z,7]
EndIf
Else
EndIf
ElseIf add=5 Then
Exit
Else
EndIf
EndIf
this is the output for the "doubles" it is more complicated because it outputs two sets of scores in columns
Code: Else
Dialog
Title string(ttl)
DropDown "Match",{"1 Singles","2 Singles","3 Singles","1 Doubles","2 Doubles","3 Doubles"},z
Text ""
Text string(player1)&" | "&string(player2)
Text " |"
Text "Games Won: "&string(gwd)&"-"&string(gld)&" | "&string(gwd)&"-"&string(gld)
Text gg&": "&string(fi1)&"/"&string(ft1)&" | "&string(fi2)&"/"&string(ft2)
Text hh&": "&string(si1)&"/"&string(st1)&" | "&string(si2)&"/"&string(st2)
DropDown "Change P1",{"","Games",gg,hh,"Exit"},add1
DropDown "Change P2",{"","Games",gg,hh,"Exit"},add2
DropDown "Change Players",{"","Change","Cancel"},chg
EndDlog
EndIf
This portion of code was to try to fix the problem of someone pressing the "esc" key and not being able to leave the loop, i really have no idea if it actually works or not tho
otherwise it is completely useless
Code: If ok=1 Then
Stop
Else
EndIf
This portion of code is to set the offset the position in the matrix because each value of z, for z=4 through z=6, holds data for 2 players
Code: If z=4 Then
0zy1
1zy2
ElseIf z=5 Then
1zy1
2zy2
ElseIf z=6 Then
2zy1
3zy2
Else
EndIf
this part adds and subtracts to the different variables and stores them in the matrix
Code: If add1=1 and add2=1 or add11 and add21 Then
Goto ttl
ElseIf add1>1 Then
If add1=2 Then
PopUp {"Win","Lost","Cancel","Minus Win","Minus Lost"},ag
If ag=1 Then
gwd+1gwd
gwd-->tenn[z+zy1,2]
gwd-->tenn[z+zy2,2]
ElseIf ag=2 Then
gld+1gld
gld-->tenn[z+zy1,3]
gld-->tenn[z+zy2,3]
ElseIf ag=3 Then
Cycle
ElseIf ag=4 Then
If gwd=0 Then
Cycle
Else
gwd-1gwd
gwd-->tenn[z+zy1,2]
gwd-->tenn[z+zy2,2]
EndIf
ElseIf ag=5 Then
If gld=0 Then
Cycle
Else
gld-1gld
gld-->tenn[z+zy1,3]
gld-->tenn[z+zy2,3]
EndIf
EndIf
ElseIf add1=3 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},af
If af=1 Then
ft1+1ft1
fi1+1fi1
ft1-->tenn[z+zy1,5]
fi1-->tenn[z+zy1,4]
ElseIf af=2 Then
ft1+1ft1
ft1-->tenn[z+zy1,5]
ElseIf af=3 Then
Cycle
ElseIf af=4 Then
If ft1=0 or fi1=0 Then
Cycle
Else
ft1-1ft1
fi1-1fi1
ft1-->tenn[z+zy1,5]
fi1-->tenn[z+zy1,4]
EndIf
ElseIf af=5 Then
If ft1=0 Then
Cycle
Else
ft1-1ft1
ft1-->tenn[z+zy1,5]
EndIf
Else
EndIf
ElseIf add1=4 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},as
If as=1 Then
st1+1st1
si1+1si1
st1-->tenn[z+zy1,7]
si1-->tenn[z+zy1,6]
ElseIf as=2 Then
st1+1st1
st1-->tenn[z+zy1,7]
ElseIf as=3 Then
Cycle
ElseIf as=4 Then
If st1=0 or si1=0 Then
Cycle
Else
st1-1st1
si1-1si1
st1-->tenn[z+zy1,7]
si1-->tenn[z+zy1,6]
EndIf
ElseIf as=5 Then
If st1=0 Then
Cycle
Else
st1-1st1
st1-->tenn[z+zy1,7]
EndIf
Else
EndIf
ElseIf add1=5 Then
Exit
Else
EndIf
ElseIf add2>1 Then
If add2=2 Then
PopUp {"Win","Lost","Cancel","Minus Win","Minus Lost"},ag
If ag=1 Then
gwd+1gwd
gwd-->tenn[z+zy2,2]
ElseIf ag=2 Then
gld+1gld
gld-->tenn[z+zy2,3]
ElseIf ag=3 Then
Cycle
ElseIf ag=4 Then
If gwd=0 Then
Cycle
Else
gwd-1gwd
gwd-->tenn[z+zy2,2]
EndIf
ElseIf ag=5 Then
If gld=0 Then
Cycle
Else
gld-1gld
gld-->tenn[z+zy2,3]
EndIf
EndIf
ElseIf add2=3 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},af
If af=1 Then
ft2+1ft2
fi2+1fi2
ft2-->tenn[z+zy2,5]
fi2-->tenn[z+zy2,4]
ElseIf af=2 Then
ft2+1ft2
ft2-->tenn[z+zy2,5]
ElseIf af=3 Then
Cycle
ElseIf af=4 Then
If ft2=0 or fi2=0 Then
Cycle
Else
ft2-1ft2
fi2-1fi2
ft2-->tenn[z+zy2,5]
fi2-->tenn[z+zy2,4]
EndIf
ElseIf af=5 Then
If ft2=0 Then
Cycle
Else
ft2-1ft2
ft-->2tenn[z+zy2,5]
EndIf
Else
EndIf
ElseIf add2=4 Then
PopUp {"In","Out","Cancel","Minus In","Minus Out"},as
If as=1 Then
st2+1st2
si2+1si2
st2-->tenn[z+zy2,7]
si2-->tenn[z+zy2,6]
ElseIf as=2 Then
st2+1st2
st2-->tenn[z+zy2,7]
ElseIf as=3 Then
Cycle
ElseIf as=4 Then
If st2=0 or si2=0 Then
Cycle
Else
st2-1st2
si2-1si2
st2-->tenn[z+zy2,7]
si2-->tenn[z+zy2,6]
EndIf
ElseIf as=5 Then
If st2=0 Then
Cycle
Else
st2-1st2
st2-->tenn[z+zy2,7]
EndIf
Else
EndIf
ElseIf add2=5 Then
Exit
Else
EndIf
Else
EndIf
this section of the code deals with the "Change Player" Drop down and resets the matrix values for that player
Code: Lbl ttl
If chg=2 Then
PopUp {"","1 Singles","2 Singles","3 Singles","1 Doubles","2 Doubles","3 Doubles"},chng
If chng=2 Then
Dialog
Title "Name Change"
Request "Player 1",a
EndDlog
For sr,2,7
0-->tenn[chng-1,sr]
EndFor
ElseIf chng=3 Then
Dialog
Title "Name Change"
Request "Player 1",b
EndDlog
For sr,2,7
0-->tenn[chng-1,sr]
EndFor
ElseIf chng=4 Then
Dialog
Title "Name Change"
Request "Player 1",c
EndDlog
For sr,2,7
0-->tenn[chng-1,sr]
EndFor
ElseIf chng=5 Then
Dialog
Title "Name Change"
Request "Player 1",d
Request "Player 2",e
EndDlog
For sr,2,7
0-->tenn[chng-1,sr]
EndFor
For sr,2,7
0-->tenn[chng,sr]
EndFor
ElseIf chng=6 Then
Dialog
Title "Name Change"
Request "Player 1",f
Request "Player 2",g
EndDlog
For sr,2,7
0-->tenn[chng,sr]
EndFor
For sr,2,7
0-->tenn[chng+1,sr]
EndFor
ElseIf chng=7 Then
Dialog
Title "Name Change"
Request "Player 1",h
Request "Player 2",i
EndDlog
For sr,2,7
0-->tenn[chng+1,sr]
EndFor
For sr,2,7
0-->tenn[chng+2,sr]
EndFor
Else
EndIf
Else
EndIf
this part of the code stores the names of the players into the matrices and stores them to the "player" and "ttl" so they can be output in the dialog boxes
Code: atenn[1,1]
btenn[2,1]
ctenn[3,1]
dtenn[4,1]
etenn[5,1]
ftenn[6,1]
gtenn[7,1]
htenn[8,1]
itenn[9,1]
If z=1 Then
aattl
tenn[1,1]player
ElseIf z=2 Then
bbttl
tenn[2,1]player
ElseIf z=3 Then
ccttl
tenn[3,1]player
ElseIf z=4 Then
ddttl
tenn[4,1]player1
tenn[5,1]player2
ElseIf z=5 Then
eettl
tenn[6,1]player1
tenn[7,1]player2
ElseIf z=6 Then
ffttl
tenn[8,1]player1
tenn[9,1]player2
Else
Goto err
EndIf
ˆ+1ˆ
this part of the code takes the values stored in the matrix and assigns them to variables so that they can be displayed by the dialog boxes
Code: If z<4 Then
tenn[z,2]gw
tenn[z,3]gl
tenn[z,4]fi
tenn[z,5]ft
tenn[z,6]si
tenn[z,7]st
ElseIf z=4 Then
tenn[z,2]gwd
tenn[z,3]gld
tenn[z,4]fi1
tenn[z,5]ft1
tenn[z,6]si1
tenn[z,7]st1
tenn[z+1,2]gwd
tenn[z+1,3]gld
tenn[z+1,4]fi2
tenn[z+1,5]ft2
tenn[z+1,6]si2
tenn[z+1,7]st2
ElseIf z=5 Then
tenn[z+1,2]gwd
tenn[z+1,3]gld
tenn[z+1,4]fi1
tenn[z+1,5]ft1
tenn[z+1,6]si1
tenn[z+1,7]st1
tenn[z+2,2]gwd
tenn[z+2,3]gld
tenn[z+2,4]fi2
tenn[z+2,5]ft2
tenn[z+2,6]si2
tenn[z+2,7]st2
ElseIf z=6 Then
For
EndFor
tenn[z+2,2]gwd
tenn[z+2,3]gld
tenn[z+2,4]fi1
tenn[z+2,5]ft1
tenn[z+2,6]si1
tenn[z+2,7]st1
tenn[z+3,2]gwd
tenn[z+3,3]gld
tenn[z+3,4]fi2
tenn[z+3,5]ft2
tenn[z+3,6]si2
tenn[z+3,7]st2
Else
EndIf
EndLoop
EndPrgm
just an fyi, any place that looks kinda wierd, i.e. two variables next to each other, there is supposed to be a --> there
Last edited by Guest on 05 Apr 2008 03:47:07 pm; edited 1 time in total |