Hey, I wrote some code that would do the law of sines and cosines for me and, when i try to run it, It says error syntax and when I press goto, it redirects me to the first prompt. (Prompt r)

Code:
Disp "Sine or Cosine"
Disp "1.Sine"
Disp "2.Cosine"
Prompt r

If r=1
Then
Goto s
Else
If r=2
Then
Goto c
Else
Disp "you stupid"

Lbl c

Prompt A,a,b,c
Else
If X=a
Then
Disp sqrt(b^2-c^2-(2bc)cosA
If X=A
Then
Disp cos⁻((a^2-b^2-c^2)/(2bc)))
Else
Disp "you stupid"

Lbl s
Prompt A,B,a,b,
If X=a
Then
Disp (bsin(A))/(sin(B))
Else
If X=A
Then
Disp sin((asinB)/b)
Else
Disp "you stupid"


Please help.
The Menu( command may be of interest to you. Also, you can only use capital letters as variables in TI-BASIC. You can use the code tags for posting code:


Code:
[code]Your lines
of code
go here[/code]
Hopefully you aren't actually using lowercase letters for your lbls, gotos, and prompts, because that is a default error right there. Staying away from lowercase letters unless in strings (and even then, they take up twice as much space as capital letters) is a great rule of thumb.
Yes. It seems lowercase letters are your problem.
But I hope that the code that you posted isnt your actual code, because there would be many other errors that will pop up after you fix the letters, such as

Code:
Prompt A,B,a,b,
(extra comma, plus lowercase variable prompts)

Code:
If r=1
Then
Goto s
Else
If r=2
Then
Goto c
Else
Disp "you stupid"

You are missing the 'End' statement in your code, which will close off an If-Then Statement. In BASIC, there is no else-if command or configuration that I am aware of, so stacking your 'Else' statements will not work either.
I recommend you download some programs from the archives and look at the code that is used to learn correct syntax, usage of commands, and general techniques for BASIC programming.
Tibasicdev is also a great resource, I recommend you take many of your basic syntax and command use questions to that site first.
To clarify what jonbush said, there are some statistics variables like r, a, b, c, d, e that are represented by lowercase letters. These can *only* be modified by the builtin statistics commands like LinReg. Accessing their values works fine, but trying to prompt for, store to, etc. throws an error.

There are also lowercase letters that can be typed when a certain flag is enabled. They look exactly the same, but don't work as variables at all. In fact, their only use is as characters in a string.
jaskinator wrote:
Hey, I wrote some code that would do the law of sines and cosines for me and, when i try to run it, It says error syntax and when I press goto, it redirects me to the first prompt. (Prompt r)

Disp "Sine or Cosine"
Disp "1.Sine"
Disp "2.Cosine"
Prompt r

If r=1
Then
Goto s
Else
If r=2
Then
Goto c
Else
Disp "you stupid"

Lbl c

Prompt A,a,b,c
Else
If X=a
Then
Disp sqrt(b^2-c^2-(2bc)cosA
If X=A
Then
Disp cos⁻((a^2-b^2-c^2)/(2bc)))
Else
Disp "you stupid"

Lbl s
Prompt A,B,a,b,
If X=a
Then
Disp (bsin(A))/(sin(B))
Else
If X=A
Then
Disp sin((asinB)/b)
Else
Disp "you stupid"



Please help.



Code:
Lbl 00
ClrHome
Menu("Law of sin/cos","Sine",01,"Cosine",02,"Exit",03
Lbl 01
Input "A=",A
Input "B=",B
Input "C=",C
If X≠A:Goto 04
Disp √(B^2-C^2-(2BC)cos(A
Disp cos⁻((A^2-B^2-C^2)/(2BC)
Pause
Goto 00
Lbl 02
Input "A=",A
Input "B=",B
If X≠A:Goto 04
Disp (Bsin(A))/(sin(B))
Disp sin((AsinB)/B)
Pause
Goto 00
Lbl 03
ClrHome
Stop
Lbl 04
ClrHome
Pause "X≠A"
Goto 00
Comments2010 wrote:
jaskinator wrote:
Hey, I wrote some code that would do the law of sines and cosines for me and, when i try to run it, It says error syntax and when I press goto, it redirects me to the first prompt. (Prompt r)

Disp "Sine or Cosine"
Disp "1.Sine"
Disp "2.Cosine"
Prompt r

If r=1
Then
Goto s
Else
If r=2
Then
Goto c
Else
Disp "you stupid"

Lbl c

Prompt A,a,b,c
Else
If X=a
Then
Disp sqrt(b^2-c^2-(2bc)cosA
If X=A
Then
Disp cos⁻((a^2-b^2-c^2)/(2bc)))
Else
Disp "you stupid"

Lbl s
Prompt A,B,a,b,
If X=a
Then
Disp (bsin(A))/(sin(B))
Else
If X=A
Then
Disp sin((asinB)/b)
Else
Disp "you stupid"



Please help.



Code:
Lbl 00
ClrHome
Menu("Law of sin/cos","Sine",01,"Cosine",02,"Exit",03
Lbl 01
Input "A=",A
Input "B=",B
Input "C=",C
If X≠A:Goto 04
Disp √(B^2-C^2-(2BC)cos(A
Disp cos⁻((A^2-B^2-C^2)/(2BC)
Pause
Goto 00
Lbl 02
Input "A=",A
Input "B=",B
If X≠A:Goto 04
Disp (Bsin(A))/(sin(B))
Disp sin((AsinB)/B)
Pause
Goto 00
Lbl 03
ClrHome
Stop
Lbl 04
ClrHome
Pause "X≠A"
Goto 00

Well then. Taking all the fun out of fixing the program yourself. Lol
Neutral
I didn't know that you could use double digit numbers for lbls and gotos. I guess I never tried it.
Caleb_Hill wrote:
Comments2010 wrote:
jaskinator wrote:
Hey, I wrote some code that would do the law of sines and cosines for me and, when i try to run it, It says error syntax and when I press goto, it redirects me to the first prompt. (Prompt r)

Disp "Sine or Cosine"
Disp "1.Sine"
Disp "2.Cosine"
Prompt r

If r=1
Then
Goto s
Else
If r=2
Then
Goto c
Else
Disp "you stupid"

Lbl c

Prompt A,a,b,c
Else
If X=a
Then
Disp sqrt(b^2-c^2-(2bc)cosA
If X=A
Then
Disp cos⁻((a^2-b^2-c^2)/(2bc)))
Else
Disp "you stupid"

Lbl s
Prompt A,B,a,b,
If X=a
Then
Disp (bsin(A))/(sin(B))
Else
If X=A
Then
Disp sin((asinB)/b)
Else
Disp "you stupid"



Please help.



Code:
Lbl 00
ClrHome
Menu("Law of sin/cos","Sine",01,"Cosine",02,"Exit",03
Lbl 01
Input "A=",A
Input "B=",B
Input "C=",C
If X≠A:Goto 04
Disp √(B^2-C^2-(2BC)cos(A
Disp cos⁻((A^2-B^2-C^2)/(2BC)
Pause
Goto 00
Lbl 02
Input "A=",A
Input "B=",B
If X≠A:Goto 04
Disp (Bsin(A))/(sin(B))
Disp sin((AsinB)/B)
Pause
Goto 00
Lbl 03
ClrHome
Stop
Lbl 04
ClrHome
Pause "X≠A"
Goto 00

Well then. Taking all the fun out of fixing the program yourself. 0x5
Neutral
I didn't know that you could use double digit numbers for lbls and gotos. I guess I never tried it.


I just wanted to provide code without syntax errors, not a complete program. This is the bare bones.
  
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 UTC - 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