Hey, I made an analog clock program in TI-BASIC a while back. I couldn't find it on my computer, so I decided to re-write it. I'm using methods more complicated than I did back then.
When I finished writing the code, the analog clock would start out fine, but then start skipping seconds, which means it was slowing down. Within the program, I was calculating what slope to use for lines for the degree angle of the hands every time the time updated. So I thought to make it faster, just have to pre-generate a list, and then look up what the slope was using the list during the program. In the end it did make it work faster (by faster I mean it took longer to slow down).
I'm told that memory leaks are caused by control structure, and not variables. When I transitioned to pre generating a list, I decided to make a bunch of gotos rather than having to re-write code, since there's no copy paste in the editor. (I didn't have access to SourceCoder at the time).
Now I need help sorting out how to keep the program from leaking. Source code is below.
Any ideas?
When I finished writing the code, the analog clock would start out fine, but then start skipping seconds, which means it was slowing down. Within the program, I was calculating what slope to use for lines for the degree angle of the hands every time the time updated. So I thought to make it faster, just have to pre-generate a list, and then look up what the slope was using the list during the program. In the end it did make it work faster (by faster I mean it took longer to slow down).
I'm told that memory leaks are caused by control structure, and not variables. When I transitioned to pre generating a list, I decided to make a bunch of gotos rather than having to re-write code, since there's no copy paste in the editor. (I didn't have access to SourceCoder at the time).
Now I need help sorting out how to keep the program from leaking. Source code is below.
SourceCoder 3 (CLOCK) wrote:
:ZStandard
:ZSquare
:AxesOff
:ClrDraw
:RecallPic 1
:DelVar L3
:84->A
:90->L3(1)
:
:For(O,2,16,1)
:A->L3(O)
:A-6->A
:End
:174->A
:For(O,17,30,1)
:A->L3(O)
:A-6->A
:End
:500->L3(31)
:Goto 6
:
:Lbl 2
:
:
:getTime->L2
:L2(3)->S
:L2(3)->C
:While S=C
:getTime->L1
:L1(1)->H
:L1(2)->Z
:L1(3)->S
:End
:ClrDraw
:RecallPic 1
:4->G
:Lbl 3
:G-1->G
:If G=3
:Then
:L1(G)->Q
:9->F
:End
:If G=2
:Then
:6->F
:L1(G)->Q
:End
:If G=1
:Then
:4->F
:If H>12
:Then
:H-12->P
:Else
:H->P
:End
:Goto 7
:End
:
:
:Goto 5
:End
:
:Lbl 6
:
:0->K
:0->B
:DelVar L4
:
:
:
:For(I,1,59,1)
:K+1->K
:If K=12
:Then
:0->K
:B+1->B
:End
:B->L4(I)
:
:
:End
:
:Goto 2
:Lbl 7
:If Z!=0
:Then
:L4(Z)->J
:Else
:0->J
:End
:
:If P*5!=60
:Then
:P*5->N
:Else
:0->N
:End
:N+J->Q
:
:
:Lbl 5
:
:If Q>30
:Then
:Q-30->T
:~1->R
:Else
:Q->T
:1->R
:End
:
:
:
:L3(T+1)->D
:If D=90 or D=500
:Then
:If D=90
:Then
:If R=~1
:Then
:0->V
:~1*F->W
:Goto 1
:Else
:0->V
:F->W
:Goto 1
:End
:Else
:If R=~1
:Then
:0->V
:F->W
:Goto 1
:Else
:0->V
:~1*F->W
:Goto 1
:End
:End
:End
:
:
:tan(D)->M
:
:R*((M*F)/sqrt(M^^2+1))->W
:If W=0
:Then
:If R=~1
:Then
:~1*F->V
:Goto 1
:Else
:F->V
:Goto 1
:End
:End
:W/M->V
:Goto 4
:Lbl 1
:
:Goto 4
:
:
:
:Lbl 4
:Line(0,0,V,W)
:
:If G=1
:Then
:Goto 2
:End
:Goto 3
:ZSquare
:AxesOff
:ClrDraw
:RecallPic 1
:DelVar L3
:84->A
:90->L3(1)
:
:For(O,2,16,1)
:A->L3(O)
:A-6->A
:End
:174->A
:For(O,17,30,1)
:A->L3(O)
:A-6->A
:End
:500->L3(31)
:Goto 6
:
:Lbl 2
:
:
:getTime->L2
:L2(3)->S
:L2(3)->C
:While S=C
:getTime->L1
:L1(1)->H
:L1(2)->Z
:L1(3)->S
:End
:ClrDraw
:RecallPic 1
:4->G
:Lbl 3
:G-1->G
:If G=3
:Then
:L1(G)->Q
:9->F
:End
:If G=2
:Then
:6->F
:L1(G)->Q
:End
:If G=1
:Then
:4->F
:If H>12
:Then
:H-12->P
:Else
:H->P
:End
:Goto 7
:End
:
:
:Goto 5
:End
:
:Lbl 6
:
:0->K
:0->B
:DelVar L4
:
:
:
:For(I,1,59,1)
:K+1->K
:If K=12
:Then
:0->K
:B+1->B
:End
:B->L4(I)
:
:
:End
:
:Goto 2
:Lbl 7
:If Z!=0
:Then
:L4(Z)->J
:Else
:0->J
:End
:
:If P*5!=60
:Then
:P*5->N
:Else
:0->N
:End
:N+J->Q
:
:
:Lbl 5
:
:If Q>30
:Then
:Q-30->T
:~1->R
:Else
:Q->T
:1->R
:End
:
:
:
:L3(T+1)->D
:If D=90 or D=500
:Then
:If D=90
:Then
:If R=~1
:Then
:0->V
:~1*F->W
:Goto 1
:Else
:0->V
:F->W
:Goto 1
:End
:Else
:If R=~1
:Then
:0->V
:F->W
:Goto 1
:Else
:0->V
:~1*F->W
:Goto 1
:End
:End
:End
:
:
:tan(D)->M
:
:R*((M*F)/sqrt(M^^2+1))->W
:If W=0
:Then
:If R=~1
:Then
:~1*F->V
:Goto 1
:Else
:F->V
:Goto 1
:End
:End
:W/M->V
:Goto 4
:Lbl 1
:
:Goto 4
:
:
:
:Lbl 4
:Line(0,0,V,W)
:
:If G=1
:Then
:Goto 2
:End
:Goto 3
Any ideas?