Michael2_3B wrote:
Some more optimizations:
-Get rid of the ending parentheses on all the menus.
-In line 61, get rid of "Goto ZZ", because Lbl ZZ comes directly after it.
-You may be able to get rid "ClrHome" in some spots - instead of doing ClrHome within each options block of code, why not do it before the menus, instead of within each option?
-Obviously, you could shorten some of the text that is displayed either on the home screen or the menus to save a little bit of space.
-toward the end of your code, you have
Code:
Output(B,8,sub("''''''''''''''''''''''''''",A,1
since all of those characters are the same, couldn't you just do this?
Code:
Output(B,8,"'
Good Job Micheal! My program got reduced from 1899 bytes to 1822 bytes...
Answers to your bullets:
-Done, got rid of the ending parenthesis
-Done, got rid of "Goto ZZ".
-Not done, because when i tired to move "ClrHome"'s around the program it messed up my screen. Previous text was appearing over new text.
-Done, thanks for that Smart Tip!!!
Here's my new code (anything more that can be optimized?):
Code:
Lbl W
Menu("Tranformation:","Translation",AA,"Reflection",BB,"Rotation",CC,"Dilation",DD,"Exit",Z
Lbl AA
1→M
ClrHome
Output(1,8,"Translation
Goto ZZ
Lbl BB
ClrHome
Menu("Reflection:","X-axis",B1,"Y-axis",B2,"Y=x",B3,"Y=-x",B4,"Go Back",W,"Exit",Z
Lbl B1
2→M
ClrHome
Output(1,10,"X-axis
Goto ZZ
Lbl B2
3→M
ClrHome
Output(1,10,"Y-axis
Goto ZZ
Lbl B3
4→M
ClrHome
Output(1,12,"Y=x
Goto ZZ
Lbl B4
5→M
ClrHome
Output(1,11,"Y=-x
Goto ZZ
Lbl CC
ClrHome
Menu("Rotation:","CW 90° (CCW 270°)",C1,"180°",C2,"CCW 90° (CW 270°)",C3,"Go Back",W,"Exit",Z
Lbl C1
6→M
ClrHome
Output(1,5,"CW 90° (CCW 270°)
Goto ZZ
Lbl C2
7→M
ClrHome
Output(1,11,"180°
Goto ZZ
Lbl C3
8→M
ClrHome
Output(1,5,"CCW 90° (CW 270°)
Goto ZZ
Lbl DD
ClrHome
Menu("Dilation:","From the Origin",D1,"Custom Origin",D2,"Go Back",W,"Exit",Z
Lbl D1
9→M
ClrHome
Output(1,6,"From the Origin
Goto ZZ
Lbl D2
10→M
ClrHome
Output(1,7,"Custom Origin
Lbl ZZ
Disp "","","Number of Points?","
Prompt D
D→dim(L₁
D→dim(L₂
D→dim(L₃
D→dim(L₄
ClrHome
1→B
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
B+3→B
If B>9
9→B
Prompt X
X→L₁(A
Prompt Y
Y→L₂(A
End
If M=1
Then
ClrHome
Disp "Move By?","
Prompt X
X+L₁→L₃
Prompt Y
Y+L₂→L₄
End
If M=2
Then
L₁→L₃
⁻L₂→L₄
End
If M=3
Then
⁻L₁→L₃
L₂→L₄
End
If M=4
Then
L₂→L₃
L₁→L₄
End
If M=5
Then
⁻L₂→L₃
⁻L₁→L₄
End
If M=6
Then
L₂→L₃
⁻L₁→L₄
End
If M=7
Then
⁻L₁→L₃
⁻L₂→L₄
End
If M=8
Then
⁻L₂→L₃
L₁→L₄
End
If M=9
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
L₁*E→L₃
L₂*E→L₄
End
If M=10
Then
ClrHome
Output(1,7,"Scale Factor?
Disp "","
Prompt E
ClrHome
Output(1,4,"Center of Dilation?
Disp "","
Prompt X,Y
L₁-X→L₅
L₂-Y→L₆
L₅*E→L₅
L₆*E→L₆
L₅+X→L₃
L₆+Y→L₄
End
augment(L₁,{L₁(1→L₁
augment(L₂,{L₂(1→L₂
augment(L₃,{L₃(1→L₃
augment(L₄,{L₄(1→L₄
ClrHome
2→B
Output(1,8,"New Points: "
Disp ""
For(A,1,D
Disp "Point"
Output(B,7,sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",A,1
Output(B,8,"'
B+2→B
If B>9
9→B
Disp {L₃(A),L₄(A)
End
"
Pause
Menu("Plot the Images?","Yes",ZX,"New Points",NP,"Main Menu",W,"Exit",Z
Lbl NP
If M=1
Goto AA
If M≥2 and M≤5
Goto BB
If M≥6 and M≤8
Goto CC
If M≥9
Goto DD
Lbl ZX
Plot1(xyLine,L₁,L₂,plotsquare)
Plot2(xyLine,L₃,L₄,plotsquare)
DispGraph
ZStandard
Pause
ClrDraw
PlotsOff
Goto W
Lbl Z
ClrHome
Stop