Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I made a clock program in ti basic for the TI-84 and other TI-BASIC calculators.

Code:

"Setup Code"
ClrDraw
ClrHome
AxesOff
1.3->Xmax
1.3->Ymax
-1.3->Xmin
-1.3->Ymin
ZSquare
Radian
Circle(0,0,1

"Tick Drawing"
For(B,0,60*pi/30,pi/30
   Line(.925+cos(B),.925*sin(B),cos(B),sin(B)
End
For(B,0,12*pi/6,pi/6
   Line(.85+cos(B),.85*sin(B),cos(B),sin(B)
End
For(B,0,4*pi/2,pi/2
   Line(.8+cos(B),.8*sin(B),cos(B),sin(B)
End

"Hand Drawing"
Lbl A
  "Split Time List Var Into 2 INT Vars"
  getTime->L1
  L1[1]->H
  L1[2]->M
 
  "Draw Hour Hand"
  Line 0,0,.5*sin((H-1)*pi/6),.5*cos((H-1)*pi/6),0
  Line 0,0,.5*sin((H-1)*pi/6),.5*cos((H*pi/6),1
 
  "Draw Minute Hand"
  Line 0,0,.7*sin((M-1)*pi/30),.7*cos((M-1)*pi/6),0
  Line 0,0,.7*sin((M-1)*pi/30),.7*cos((M*pi/30),1
Goto A


Can I get some feedback on this code? Good Idea Also, I changed my email on my old acct @izder456 bc i acquired a new email address and I got banned Surprised . Can I get this account recovered Idea ? I didn't know that was a rule Wink .
Does that code even work for you? It doesn't work for me. Here are some things that immediately stand out to me and some code fixes.
1. You used the minus sign (-) rather than the negative sign (~) on the 7 and 8th line.
2. You used double quote comments (") rather than the double backslash (//) comments. // comments don't get put in your program when you compile it from SC and therefor don't slow down your program like " comments do.
3. Perhaps you should add that this will only work on the monochrome TI 84s since it didn't work on my CE. add the command that turns off the y= functions since I thought this program wasn't working, only to realize a while later that my calculator was just graphing something outside of the window range.
3.5. Utilize the Graph DataBase (GDB) function so you can reset the users window and other data back to what it was before they ran the program. It's a nice touch that makes users really appreciate the programmer.
4. On lines 28 and 29 you used brackets when you need to use parenthesis.
5. Line 32,33,36,37 you put a space after the Line( command rather than an open parenthesis
6. line 33,37 there should not be a 1 as the last argument.
7. I don't understand what the code under "tick drawing" is suppose to do, it distorts the clock face for me.
8. You used a Lbl/Goto loop rather than a While or Repeat loop. I highly suggest not using the Lbl loop since it creates a infinite loop you can't get out of unless you press [on] which is not a very clean exit option.
While loops allow you to loop until a condition is not met.
Repeat loops allow you to loop until a condition is met. I suggest using either one of these loops and utilizing the getKey command to detect when the user wants to quit the program.

Here's the final, working code I ended up with.

Code:
//Stores the current window to GDB 1 to be recalled later
StoreGDB 1
//sets up a friendly window
ClrDraw
AxesOff
FnOff
1.3->Xmax
1.3->Ymax
~1.3->Xmin
~1.3->Ymin
ZSquare
//changes mode to Radians
Radian
//draws the clock face
Circle(0,0,1

//Draws the clock hands
//THis loops until the user presses any key.
Repeat getKey
  //Split Time List Var Into 2 INT Vars
  getTime->L1
  L1(1)->H
  L1(2)->M
 
  //Draw Hour Hand
  Line(0,0,.5*sin((H-1)*pi/6),.5*cos((H-1)*pi/6),0
  Line(0,0,.5*sin((H-1)*pi/6),.5*cos((H*pi/6)
 
  //Draw Minute Hand
  Line(0,0,.7*sin((M-1)*pi/30),.7*cos((M-1)*pi/6),0
  Line(0,0,.7*sin((M-1)*pi/30),.7*cos((M*pi/30
End
//Resets the graph back to its original state
FnOn
RecallGDB 1


EDIT:
Quote:
Can I get some feedback on this code? Good Idea Also, I changed my email on my old acct @izder456 bc i acquired a new email address and I got banned Surprised . Can I get this account recovered Idea ? I didn't know that was a rule Wink .
Changing your email isn't against the rules. You'll want to PM KermMartian, Tari, or PT_ about account recovery.
sorry I originally wrote it on a voyage 200 and I accidentally used a mix of the syntax of 68k and ti-basic
TheLastMillennial wrote:
Does that code even work for you? It doesn't work for me. Here are some things that immediately stand out to me and some code fixes.
1. You used the minus sign (-) rather than the negative sign (~) on the 7 and 8th line.
2. You used double quote comments (") rather than the double backslash (//) comments. // comments don't get put in your program when you compile it from SC and therefor don't slow down your program like " comments do.
3. Perhaps you should add that this will only work on the monochrome TI 84s since it didn't work on my CE. add the command that turns off the y= functions since I thought this program wasn't working, only to realize a while later that my calculator was just graphing something outside of the window range.
3.5. Utilize the Graph DataBase (GDB) function so you can reset the users window and other data back to what it was before they ran the program. It's a nice touch that makes users really appreciate the programmer.
4. On lines 28 and 29 you used brackets when you need to use parenthesis.
5. Line 32,33,36,37 you put a space after the Line( command rather than an open parenthesis
6. line 33,37 there should not be a 1 as the last argument.
7. I don't understand what the code under "tick drawing" is suppose to do, it distorts the clock face for me.
8. You used a Lbl/Goto loop rather than a While or Repeat loop. I highly suggest not using the Lbl loop since it creates a infinite loop you can't get out of unless you press [on] which is not a very clean exit option.
While loops allow you to loop until a condition is not met.
Repeat loops allow you to loop until a condition is met. I suggest using either one of these loops and utilizing the getKey command to detect when the user wants to quit the program.

Here's the final, working code I ended up with.

Code:
//Stores the current window to GDB 1 to be recalled later
StoreGDB 1
//sets up a friendly window
ClrDraw
AxesOff
FnOff
1.3->Xmax
1.3->Ymax
~1.3->Xmin
~1.3->Ymin
ZSquare
//changes mode to Radians
Radian
//draws the clock face
Circle(0,0,1

//Draws the clock hands
//THis loops until the user presses any key.
Repeat getKey
  //Split Time List Var Into 2 INT Vars
  getTime->L1
  L1(1)->H
  L1(2)->M
 
  //Draw Hour Hand
  Line(0,0,.5*sin((H-1)*pi/6),.5*cos((H-1)*pi/6),0
  Line(0,0,.5*sin((H-1)*pi/6),.5*cos((H*pi/6)
 
  //Draw Minute Hand
  Line(0,0,.7*sin((M-1)*pi/30),.7*cos((M-1)*pi/6),0
  Line(0,0,.7*sin((M-1)*pi/30),.7*cos((M*pi/30
End
//Resets the graph back to its original state
FnOn
RecallGDB 1


Here is the original code for 68k Calculators modified with your suggestions. it doesn't look like 68k uses the repeat loop:


Code:

//Stores the current window to GDB 1 to be recalled later
StoGDB 1
//sets up a friendly window
ClrDraw
setGraph("axes","off")
FnOff
1.3->Xmax
1.3->Ymax
~1.3->Xmin
~1.3->Ymin
ZoomSqr
//changes mode to Radians
setMode("Angle","RADIAN")
//draws the clock face
Circle 0,0,1

//Draws the clock hands
//This loops until the user presses any key.
while getKey!=1
  //Split Time List Var Into 2 INT Vars
  getTime()->L1
  L1[1]->H
  L1[2]->M
 
  //Draw Hour Hand
  Line 0,0,.5*sin((H-1)*pi/6),.5*cos((H-1)*pi/6),0
  Line 0,0,.5*sin((H-1)*pi/6),.5*cos((H*pi/6)
 
  //Draw Minute Hand
  Line 0,0,.7*sin((M-1)*pi/30),.7*cos((M-1)*pi/6),0
  Line 0,0,.7*sin((M-1)*pi/30),.7*cos((M*pi/30
EndWhile
//Resets the graph back to its original state
FnOn
RclGDB 1
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement