Hi so I made a program but my labeling options keep overlapping

Here is what I have done so far:


Code:

:Input "Ka Value", K
:Menu("Select Option","pH midpoint",1,"pH buffer",2,"EXIT",0
:Lbl 1
:-log(K)->P
:Disp "pH at midpoint= ",P
:Lbl 2
:Input "Buffer base []: ",B
:Input "Buffer acid []: ",A
:-log(K)+log(B/A)->P
:Disp "pH= ",P
:Lbl 0
:STOP


The problem I am having is that whenever I use Lbl 1, I get:
ph AT Midpoint=
123456789...
Buffer Base []:

How do I make it so that Buffer base don't appear if I select the first option?

Thanks,

L
The program doesn't stop execution when it hits another Lbl, you might need a 'Return' at the end of your code for the specific label.
on second thought... its not a big deal because I don't want to re-type out all the rest of my labels/options again, and I'm not exactly sure what I would have to put in the return statement.

Thanks
You don't have to re-type out anything. In order to insert more code, simply press [2nd] and then [del]. Then, press enter to insert a blank line.

Here is a solution that you can put after the midpoint line:
Code:

Disp "pH at midpoint= ",P
Stop

This will make the program stop before hitting Lbl 2.

If you want, you could also make the program loop back to the menu after displaying the values. Note, you must press Enter to continue after the values are displayed.

Code:

Lbl 3
Input "Ka Value", K
Menu("Select Option","pH midpoint",1,"pH buffer",2,"EXIT",0
Lbl 1
-log(K)->P
Disp "pH at midpoint= ",P
Pause
Goto 3
Lbl 2
Input "Buffer base []: ",B
Input "Buffer acid []: ",A
-log(K)+log(B/A)->P
Disp "pH= ",P
Pause
Goto 3
Lbl 0
Stop
Michael2_3B wrote:
You don't have to re-type out anything. In order to insert more code, simply press [2nd] and then [del]. Then, press enter to insert a blank line.

Here is a solution that you can put after the midpoint line:
Code:

Disp "pH at midpoint= ",P
Stop

This will make the program stop before hitting Lbl 2.

If you want, you could also make the program loop back to the menu after displaying the values. Note, you must press Enter to continue after the values are displayed.

Code:

Lbl 3
Input "Ka Value", K
Menu("Select Option","pH midpoint",1,"pH buffer",2,"EXIT",0
Lbl 1
-log(K)->P
Disp "pH at midpoint= ",P
Pause
Goto 3
Lbl 2
Input "Buffer base []: ",B
Input "Buffer acid []: ",A
-log(K)+log(B/A)->P
Disp "pH= ",P
Pause
Goto 3
Lbl 0
Stop


Wow... That is absolutely ground breaking, I guess I've been programming things wrong this whole time becuase each time I'd want to insert something new I would delete the entire previous code and reprogram everything just because I didn't know of the insert function - that is soo powerful!

Thank you! Now I finish my other programs- which leads me to another question however : unrelated to this program

The problem I'm having is I want to make a display that says something if the number is greater than 0, and if its less than 0, it will say another phrase.

So for example, I get an answer that says Entropy of universe= J/K 1000
then in the next line it will say product favored, but if the Entropy of universe = J/K -1000
the next line will display reactant favored

how would I program that?

Thanks for your insight

L
Sounds like you need an If statement. Wink

You can check if your variable is greater than a number, less than a number, equal to and more!

Lets assume your variable is Z.

Code:

If Z>0
Then
Disp " Entropy of universe= J/K
Disp Z
Disp "Product favored.
End
If Z<0
Then
Disp "Entropy of universe=J/K
Disp Z
Disp "Reactant favored
End


Let me know if this helps!
Unicorn wrote:
Sounds like you need an If statement. Wink

You can check if your variable is greater than a number, less than a number, equal to and more!

Lets assume your variable is Z.

Code:

If Z>0
Then
Disp " Entropy of universe= J/K
Disp Z
Disp "Product favored.
End
If Z<0
Then
Disp "Entropy of universe=J/K
Disp Z
Disp "Reactant favored
End


Let me know if this helps!

Okay so that's the easy to understand code, now if you want, you can complicate the code a little to make it shorter, which is always nice, and generally a good habit to get into.

Code:
Disp "Entropy of universe=J/K",Z,sub("ReactantProduct ",1+8(abs(Z)=Z),8)+" favored.

All in one line Rolling Eyes
  
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