Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: holmes221b on December 26, 2010, 10:57:29 pm
-
Strings and I have a love-hate affair going on right now, particularly where my program Chemitab 83+ is concerned. I can't get the program to display all 112 elements correctly. It displays Hydrogen fine, though, and at one point today, I got it to display Hydrogen for all 112 elements. The exit option ('0') also works fine too.
Here's a rough concept of what the code looks like (I'd be completely insane to provide the entire code like this, it's almost 1k lines in length):
:Lbl A
:Input "NUMBER? ",N
:If N=0:Goto X
:If N=1:Then
:"HYDROGEN"->Str1
:"H"->Str2
:Goto B
:If N=2:Then
:"HELIUM"->Str1
:"HE"->Str2
:GotoB
...
:If N=112:Then
:"COPERNICIUM"->Str1
:"CN"->Str2
:Goto B
:Lbl B
:ClrHome
:Disp Str2
:Disp Str1
:Pause
:Goto A
...
-
you need End's with those if/then statements.
If X=1
Disp "x is 1"
Disp "always displayed"
If X=1:Then
Disp "X=1"
Disp "Displayed when x=1"
End
by the way, 1000 posts
-
So how would I use End in my program?/me is kinda confused.
-
End ends a Then, Repeat, For or While Loop.
-
So how would I use End in my program?/me is kinda confused.
If (expression):Then
//code executed if expression is true
//more code being executed.
End
//code executed always
If (expression)
//code executed if expression is true
//code executed always
if you don't understand this, you may want to search TI|BD's starter tutorial
press [Prgm][7] to get the End token.
-
It essentially defines a block of the if statement. In Basic, you don't need one for If, unless you want multiple lines to run. So:
If A=1
line A
line B
line C
if A=1, then Line A would be run. but A and B are run here.
if A=1:Then
line A
line B
End
line C
the same thing applies for Repeat and While, except they must be used with an End. (No Then, either. So this is a repeat loop that waits for a keypress)
Repeat Getkey
End
-
I probably should clarify that the code in nemo's post confused me...
-
If you use an If conditional (no Then), only the following line will be executed if the conditional is true.
If you use an If conditional (with Then), then that entire block of code until the next End with be executed when the conditional is true.
-
Ah, okay.
Now it's all clear to me.
Nice avatar, by the way.
-
:) Thank you, sir.
-
Ma'am. This ain't the military.
-
Ohshi-
You're a legit girl.
Oh shi-
o.o
-
And it's that time of the month for me too--so it's impossible for me to forget that fact for myself.
-
Uhm.
Well.
You have my sincerest apologies, madame. (Ma'am seems so... informal.)
-
Everyone also forgot to mention that you need End at the end of an If/Then/Else statement. If you need anymore help just let us now :)
-
Forgot to mention here that I've gotten it to work.
Everyone also forgot to mention that you need End at the end of an If/Then/Else statement. If you need anymore help just let us now :)
It's alright, though, I already knew about that anyways. And thanks for the offer, but I already knew that everyone here is willing to help me out if I just ask (I speak from experience, in fact).
-
Cool to hear. ;D
About End statements, in TI-BASIC for the 83+ it's even more confusing because unlike other languages, there's one End instruction for everything, instead of EndWhile, EndIf, Next and EndRepeat, so when you have about 5 nested ifs/for/whiles along with a few scattered ifs in your code, it gets confusing to figure out how many End commands you need at the end.
-
/me wasn't able to start a new thread for this (school connection isn't allowing me to start new topics anywhere on Omnimaga)
So today in Precalculus II, we started learning about angles and their measure (that's practically the actual title of the section). During that time, I came up with two different ideas for new programs to code:
-a program to convert radians to degrees, minutes, seconds as well as convert degrees, minutes, seconds to radians
-a program to convert decimals to degrees, minutes, seconds as well as convert degrees, minutes, seconds to decimals.
My question is this: Is it possible to create a program to do the latter? The reason I ask this is because in my textbook it mentions that to convert decimals to degrees, you have to change the calculator's mode to get the correct answer.
-
My question is this: Is it possible to create a program to do the latter? The reason I ask this is because in my textbook it mentions that to convert decimals to degrees, you have to change the calculator's mode to get the correct answer.
Very likely. I'm not sure how to do it, though.
-
-a program to convert decimals to degrees, minutes, seconds as well as convert degrees, minutes, seconds to decimals.
My question is this: Is it possible to create a program to do the latter? The reason I ask this is because in my textbook it mentions that to convert decimals to degrees, you have to change the calculator's mode to get the correct answer.
It's possible and actually quite easy. I don't have my link cable right now, so here's the code:
Menu("","▶DMS",A,"▶Dec,B
Lbl A
Input "Decimal? ",A
ClrHome
60fPart(A→B
60fPart(B→C
Disp int(A),int(B),int(Ans
Pause
Stop
Lbl B
Input "D? ",A
Input "M? ",B
Input "S? ",C
(C/60+B)/60+A
Disp Ans
/me waits for Runer to reduce the code size down to six bytes with his incredible optizimations
-
Instead of
Input "D? ",A
Input "M? ",B
Input "S? ",C
, maybe you could use
Prompt D,M,S
instead? :P
And maybe change Decimal to DECIMAL.
EDIT: Instead of:
Disp int(A),int(B),int(Ans
Pause
do this:
Disp int(A),int(B
Pause int(Ans
EDIT2: I think you misspelled the first line. It should be Menu("","▶DMS",A,"▶Dec",B, not Menu("","▶DMS",A,"▶Dec,B
-
My question is this: Is it possible to create a program to do the latter? The reason I ask this is because in my textbook it mentions that to convert decimals to degrees, you have to change the calculator's mode to get the correct answer.
Not only is it possible, it's built into TIOS.
-
Not only is it possible, it's built into TIOS.
Can you tell I don't have an owner's manual for my calculator? xD
-
Can you tell I've read mine cover to cover? XD
-
I think I can make a smaller program than what you've all come up with for me (if you remove the "fluff" I added to make it into a "proper" program)...whether or not it actually works though, I don't know yet, I haven't tried this out on my calc yet. Also, it's set up with the assumption that you have already set your mode to DEGREE.
:Lbl A
:Input "DMS=1, DEC=2", N
:If N=1:Then
:ClrHome
:Prompt D,M,S
:Disp DºM'S''
:Pause
:Goto B
:End
:If N=2:Then
:ClrHome
:Prompt N
:Disp N▶DMS
:Pause
:Goto B
:End
:If N≠1
:If N≠2
:Then
:ClrHome
:Disp "TRY AGAIN!"
:Pause
:Goto A
:End
:Lbl B
:ClrHome
:Input "PRESS 1 TO REPEAT", X
:If X=1:Then
:Goto A
:End
:If X≠1:Then
:Stop
edit: Okay it doesn't work. Keeps getting ERR:SYNTAX on the DMS to DEC section of the code.
-
Some of those If's won't work, I don't think...
-
They all should, this code is based off of Chemitab 83+
doesn't mean that they will work, though.
-
Try this:
:Lbl A
:Input "DMS=1, DEC=2", N
:ClrHome
:If N=1
:Then
:Prompt D,M,S
:Disp DºM'S''
:Goto B
:End
:If N=2
:Then
:Prompt N
:Disp N▶DMS
:Goto B
:End
:If N≠1 and N≠2
:Then
:ClrHome
:Disp "Try again!"
:Pause
:Goto A
:End
:Lbl B
:Pause
:ClrHome
:Input "PRESS 1 TO REPEAT", X
:If X=1
:Goto A
:If X≠1
:Stop
-
Er, Raylin's right.
When you have more than one line in a conditional, you must always have
If <condition>:Then
<Code>
<Code>
End
If you do not have a :Then statement, then the calculator does this instead:
If <Condition>
<line of Code to be executed if the condition is true and skipped if false>
<line of code to be executed if the condition is false and skipped if true>
<rest of code>
Any End statements are regarded as not having associated commands and bring up errors. You didn't follow the conditionals correctly, so that's probably at least one problem with your code.
-
I can't even get that far in it, because of the ERR:SYNTAX.
It doesn't like the M' part.
-
Try Disp D,"º",M," ' "," '' "or Text to display them.
-
If you do not have a :Then statement, then the calculator does this instead:
If <Condition>
<line of Code to be executed if the condition is true and skipped if false>
<line of code to be executed if the condition is false and skipped if true>
<rest of code>
Shouldn't this be:If <Condition>
<line of Code to be executed if the condition is true and skipped if false>
<rest of code>
? ???
-
Er, yes. Thanks for correcting that.