Tell me what yall think. I just finished the program think it can be shortened or made any more efficient?

Code:

ClrHome
Disp "Programmed by  *","Alex Capistran *","****************","Use Kelvin for","Temperature.","mmHg 4 Pressure"
Pause "Press ENTER"
ClrHome
8.314->R

Lbl 7
Menu("Looking for?","T1",1,"T2",2,"P2",3,"P1",4,"deltaHvap",5,"Temp Convert",6,"Quit",8)
Lbl 1
ClrHome
Disp "Enter values","accordingly","T2,P1,P2,deltaHvap"
Prompt A,B,C,D
(R/D)->X
(ln(B/C))->Y
((~A)/((A*X*Y)-1))->G
Disp "Answer is",G,"K"
Pause "Press ENTER"
Goto 7

Lbl 2
ClrHome
Disp "Enter values","accordingly","T1,P1,P2,deltaHvap"
Prompt A,B,C,D
(D/R)->X
(ln(B/C))->Y
((A)/((A*X*Y)+1))->G
Disp "Answer is",G,"K"
Pause "Press ENTER"
Goto 7

Lbl 3
ClrHome
Disp "Enter values","accordingly","T1,T2,P1,deltaHvap"
Prompt A,B,C,D
(D/R)->X
(((A-B)/(AB))*X)->Y
(C/(e^(Y)))->E
Disp "Answer is",E,"mmHg"
Pause "Press ENTER"
Goto 7

Lbl 4
ClrHome
Disp "Enter values","accordingly","T1,T2,P2,deltaHvap"
Prompt A,B,C,D
(D/R)->X
(((A-B)/(AB))*X)->Y
(C*(e^(Y)))->E
Disp "Answer is",E,"mmHg"
Pause "Press ENTER"
Goto 7

Lbl 5
ClrHome
Disp "Enter values","accordingly"," T1,T2,P1,P2","****************"
Prompt A,B,C,D
((R*(ln(C/D)))/(((A-B)/(AB))))->H
Disp "Answer is",H,"J/mol"
Pause "Press ENTER"
Goto 7

Lbl 6
ClrHome
Menu("Convert Temp","To F",F,"To C",C,"To K",K,"Back",7)

Lbl F
Menu("Choose","Celcius",CF,"Kelvin",KF)
Lbl CF
Disp "Enter degree C"
Prompt C
((C*(9/5))+32)->F
Disp F,"degrees F"
Pause "Press ENTER"
Goto 6
Lbl KF
Disp "Enter Kelvin"
Prompt K
((K*(9/5))-459.67)->F
Disp F,"degrees F"
Pause "Press ENTER"
Goto 6

Lbl C
Menu("Choose","Fahrenheit",FC,"Kelvin",KC)
Lbl FC
Disp "Enter degree F"
Prompt F
((F-32)*(5/9))->C
Disp C,"degrees C"
Pause "Press ENTER"
Goto 6
Lbl KC
Disp "Enter Kelvin"
Prompt K
(K-273)->C
Disp C,"degrees C"
Pause "Press ENTER"
Goto 6

Lbl K
Menu("Choose","Fahrenheit",FK,"Celcius",CK)
Lbl FK
Disp "Enter Degree F"
Prompt F
((F+459.67)*(5/9))->K
Disp K,"Kelvin"
Pause "Press ENTER"
Goto 6
Lbl CK
Disp "Enter Degree C"
Prompt C
(C+273)->K
Disp K,"Kelvin"
Pause "Press ENTER"
Goto 6

Lbl 8
Stop
One thing: To use lowercase letters, you'll need textlib, or something that allows you to put in lowercase letters. Until then, I suggest that you make all of the text capitalized, including the program name.


Also, instead of:

Code:

ClrHome
Disp "Enter values","accordingly","T2,P1,P2,deltaHvap"
Prompt A,B,C,D

make that

Code:
Clrhome
Input "T2:,A
Input "P1:,B
Input "P2:",C
Input "DeltaHvap:",D


This should minimize any accidental errors with inputting data. You can also do this for all other instances that you use Prompt.

FYI: Input can be used to store any, well, inputted number or string to a variable. Just don't try to store "ABCDEF" to a variable other than a string.
caleb1997 wrote:
One thing: To use lowercase letters, you'll need textlib, or something that allows you to put in lowercase letters. Until then, I suggest that you make all of the text capitalized, including the program name.


i mean i did the asmprgm option on the calc so i should be fine and i have to capitalize before i transfer anyway or else it wont go onto the calc
Actually, I'm pretty sure you only have to have the shell to actually write the lowercase letters, however to put it online/transfer it, the lowercase letters should be completely fine.
Note that a lowercase letter uses 2 bytes while an uppercase letter uses only 1.
DWMelon wrote:
Note that a lowercase letter uses 2 bytes while an uppercase letter uses only 1.


Indeed. If you want lowercase letters, go for it. But uppercase letters take only 1 byte, so if you want to save space, go for capital letters.

But do what you want. It's your program, after all.
You have many things like

Code:
(R/D)->X
(ln(B/C))->Y
((~A)/((A*X*Y)-1))->G

First, why I chose this piece, it can be triple-optimized (I mean three things you may optimize).

You may actually merge the three calculations:

Code:
((~A)/((A*(R/D)*(ln(B/C)-1))->G


Then you may leave out the parathenses around it (Why should there be parathenses?) And, a special thing about TI-Basic, you don't need to close anything (Quotation marks, parathenses,...) at the end of a line or before a sto sign:

Code:
(~A)/((A*(R/D)*(ln(B/C)-1->G


Then, the asterisks for multiplication may be omitted too, just like in real math:

Code:
(~A)/((A(R/D)(ln(B/C)-1->G


And now case-specific stuff, for that line only (and maybe some other lines too, but fewer):
(~A) in that case becomes just ~A because the result will be always the same:

Code:
~A/((A(R/D)(ln(B/C)-1->G


Also, since you display that number in the following line, use Ans instead of G, Ans is (Milliseconds only, but still) faster. It is a good habit to use high performance code even where it isn't needed, that will help you using it in places where it actually should be and make your code similar to other pieces of your code.

If you won't need that number anymore, like in this case, you don't even need to store it to G. Just do

Code:
Disp "Stuff", n, ~A/((A(R/D)(ln(B/C)-1

(Calculate it in even less lines, overwrite one less variable).

Remember this is only one line I optimised for you, and I am sure some people like Weregoose (He is an actual TI-Basic legend alive!) can compress it even more. So, let the other lines be an exercise for you! Smile

Also, before you even really start doing this, try to use as few as possible Goto's, Lbl's and Menu('s, they make your code harder to follow than a bunch of spaghetti (it is even called spaghetti-code). Use loops and If:Then:Else:End wherever possible instead of labels. Even better, try to avoid them at all. That most often saves tens of bytes and seconds of time.

So, good luck! Feel free to ask questions and post your results please, once you are done.
  
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