Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display variable and string on same line (TI-Basic)

Tags:

ti-basic

In most programming languages, you can mix and match strings with variables during output. However, I can't seem to find a good way to do so. Here is my code:

Prompt A,B
√(A^2+B^2)->C
If iPart(C)≠C
Then
Disp "C = √(",C
Else
Disp "C = ",C
End
Goto ED

Label ED

Unfortunately, with this code, it ends up printing like so:

A? 3
B? 5
C = √(
              34
            Done

This is not what I want. I would love to be able to have it print C = √(34), but I currently can't find any way to mix variables and strings. Any help would be appreciated.

like image 510
jaysoncopes Avatar asked Oct 15 '14 20:10

jaysoncopes


2 Answers

I know this is a little late, but it might help others as well. The Output(... command would be used in this case.

Prompt A,B
√(A^2+B^2)->C
If iPart(C)≠C
Then
Disp "C = √(",C
Output(3,7,C
Else
Disp "C = ",C
End

Just remember that the home display is 16x8 characters, which you may need as you plan out how and where to display your results.

like image 164
Richard Chase Avatar answered Sep 30 '22 12:09

Richard Chase


I know this thread is very dead but for posterity:

If you have a TI-84+CE on version 5.2 or later, you can use the toString( function. If you do not, if the output string will always be the same size, simply use Output(. If this does not generate the desired effect, you can use:

:{0,.5,1→L₁
:NL₁→L₂
:Med-Med Y₁
:Equ►String(Y₁,Str1
:sub(Str1,1,length(Str1)-3→Str1
like image 39
Zingzing Jr. Avatar answered Sep 30 '22 12:09

Zingzing Jr.