I found a small program that was released in ticalc.org's last batch of updates, Analogue (sic) Clock. The original code:
Horrendous, right? There's no reason for a program to be that long. In fact, this is some of the worst coding I've ever seen. Here's my initial optimization of it; can anyone make it better?
BASIC Code wrote:
:PlotsOff
:FnOff
:AxesOff
:Degree
:ClrDraw
:1→Xmin
:95→Xmax
:63→YMax
:1→Ymin
:For(θ,25,28,0.2
:Circle(47,31,θ
:End
:For(θ,0,360,30
:sin(θ→A
:cos(θ→B
:A*25→D
:D+47→D
:B*25→E
:E+31→E
:A*22→F
:F+47→F
:B*22→G
:G+31→G
:Line(D,E,F,G
:End
:getTime→L2
:getTime→L1
:For(A,1,10
:A-1→A
:getTime→L1
:Lbl C
:getTime→L2
:If L1(3)=L2(3
:Goto C
:getTime→L1
:10→C
:L1(1→H
:L1(2→M
:L1(3→S
:M/60→T
:M/60→E
:S/60→N
:S/60→F
:If H>12
:H-12→H
:H/12→U
:T*360→T
:U*360→U
:N*360→N
:E*30→E
:F*6→F
:U+E→U
:T+F→T
:sin(T→X
:cos(T→Z
:sin(U→Q
:cos(U→R
:sin(N→V
:cos(N→W
:20*X→X
:20*Z→Z
:14*Q→Q
:14*R→R
:17*V→V
:17*W→W
:Line(47,31,L3(1)+47,L3(2)+31,0
:Line(47,31,V+47,W+31
:Line(47,31,L3(3)+47,L3(4)+31,0
:Line(47,31,Q+47,R+31
:Line(47,31,L3(5)+47,L3(6)+31,0
:Line(47,31,X+47,Z+31
:Line(46,32,48,32
:Line(46,30,48,30
:Line(46,30,46,32
:Line(48,30,48,32
:V→L3(1
:W→L3(2
:Q→L3(3
:R→L3(4
:X→L3(5
:Z→L3(6
:End
Generated by SourceCoder, © 2005 Cemetech
:FnOff
:AxesOff
:Degree
:ClrDraw
:1→Xmin
:95→Xmax
:63→YMax
:1→Ymin
:For(θ,25,28,0.2
:Circle(47,31,θ
:End
:For(θ,0,360,30
:sin(θ→A
:cos(θ→B
:A*25→D
:D+47→D
:B*25→E
:E+31→E
:A*22→F
:F+47→F
:B*22→G
:G+31→G
:Line(D,E,F,G
:End
:getTime→L2
:getTime→L1
:For(A,1,10
:A-1→A
:getTime→L1
:Lbl C
:getTime→L2
:If L1(3)=L2(3
:Goto C
:getTime→L1
:10→C
:L1(1→H
:L1(2→M
:L1(3→S
:M/60→T
:M/60→E
:S/60→N
:S/60→F
:If H>12
:H-12→H
:H/12→U
:T*360→T
:U*360→U
:N*360→N
:E*30→E
:F*6→F
:U+E→U
:T+F→T
:sin(T→X
:cos(T→Z
:sin(U→Q
:cos(U→R
:sin(N→V
:cos(N→W
:20*X→X
:20*Z→Z
:14*Q→Q
:14*R→R
:17*V→V
:17*W→W
:Line(47,31,L3(1)+47,L3(2)+31,0
:Line(47,31,V+47,W+31
:Line(47,31,L3(3)+47,L3(4)+31,0
:Line(47,31,Q+47,R+31
:Line(47,31,L3(5)+47,L3(6)+31,0
:Line(47,31,X+47,Z+31
:Line(46,32,48,32
:Line(46,30,48,30
:Line(46,30,46,32
:Line(48,30,48,32
:V→L3(1
:W→L3(2
:Q→L3(3
:R→L3(4
:X→L3(5
:Z→L3(6
:End
Generated by SourceCoder, © 2005 Cemetech
Horrendous, right? There's no reason for a program to be that long. In fact, this is some of the worst coding I've ever seen. Here's my initial optimization of it; can anyone make it better?
BASIC Code wrote:
:PlotsOff
:FnOff :AxesOff
:Degree :ClrDraw
:1→Xmin:1→deltaX
:1→Ymin:1→deltaY
:For(θ,25,28,.2
:Circle(47,31,θ
:End
:For(θ,0,360,30
:sin(θ→A:cos(θ→B
:Line(25A+47,25B+31,22A+47,22B+31
:End
:getTime→L2
:getTime→L1
:While not(getKey
:While L1(3)=L2(3
:getTime→L2
:End
:L1(1→H
:L1(2→M
:L1(3→S
:M/2+30(H-12(H>12→U
:6M+.1S→T
:Line(47,31,V+47,W+31,0
:Line(47,31,Q+47,R+31,0
:Line(47,31,X+47,Z+31,0
:20sin(T→X
:20cos(T→Z
:14sin(U→Q
:14cos(U→R
:17sin(6S→V
:17cos(6s→W
:Line(47,31,V+47,W+31
:Line(47,31,Q+47,R+31
:Line(47,31,X+47,Z+31
:PtOn(47,31,2
:End
Generated by SourceCoder, © 2005 Cemetech
:FnOff :AxesOff
:Degree :ClrDraw
:1→Xmin:1→deltaX
:1→Ymin:1→deltaY
:For(θ,25,28,.2
:Circle(47,31,θ
:End
:For(θ,0,360,30
:sin(θ→A:cos(θ→B
:Line(25A+47,25B+31,22A+47,22B+31
:End
:getTime→L2
:getTime→L1
:While not(getKey
:While L1(3)=L2(3
:getTime→L2
:End
:L1(1→H
:L1(2→M
:L1(3→S
:M/2+30(H-12(H>12→U
:6M+.1S→T
:Line(47,31,V+47,W+31,0
:Line(47,31,Q+47,R+31,0
:Line(47,31,X+47,Z+31,0
:20sin(T→X
:20cos(T→Z
:14sin(U→Q
:14cos(U→R
:17sin(6S→V
:17cos(6s→W
:Line(47,31,V+47,W+31
:Line(47,31,Q+47,R+31
:Line(47,31,X+47,Z+31
:PtOn(47,31,2
:End
Generated by SourceCoder, © 2005 Cemetech