So i made a simple program that calculates the cross-product of two 3D vectors on my TI-84 Plus Calculator. I would like for the output to look like this: XI+YJ+ZK, however i dont know how to concatenate number values as they are stored in variables onto strings, so i dont know how to print the output as a single disp call. Right now i call disp 6 times, the first prints out the x-value, the next prints "I+", the next out the y-value, then "J+", the next out the z-value, then "K+". This prints it to many different lines, is it possible to compress the output, both the little strings and the variable values, into one output? Thanks
2 Answers
Concatenating numbers as strings is not possible on the home screen of the calculator without something like nbadal's solution; however, it is easy on the graph screen. The Text(
command can be given multiple content arguments, all of which are converted to strings and displayed on the graph screen. Inserting a "-1" as the first argument also displays the text in large font. So
Text(0,0,4,"I+",5,"J+",π,"K")
would display
4I+5J+3.141592654K
on the top-left corner of the screen. For more information, see this page on tibasicdev.
In your scenario, since you are storing the values for I, J, and K in X, Y, and Z, use the following snippet of code after you obtain the values of your variables:
Text(0,0,X,"I+",Y,"J+",Z,"K")

- 592
- 4
- 15
-
@BobJones It's not necessary to close quotes in this dialect is TI-BASIC. Whether it's good style is another question. – lirtosiast Mar 31 '16 at 04:43
Like @NickBadal said, converting numbers to strings is a pain in the ass (the other way is remarkably simple: just expr(
). There are two methods for doing so, and neither is very clean or efficient.
If I were making a cross product program, I would rather do it like this:
Disp X
Output(1,1,"i=
Disp Y
Output(2,1,"j=
Disp Z
Output(3,1,"k=
That way you only get 3 lines of output instead of 6. Besides, then you don't have to deal with the messiness of having an "Xi+Yj+Zk" form string that runs off the screen when the components turn out to be decimals.
If you really want to keep the i, j, and k components all in one line, you might want to consider outputting the vector as a list:
X→L₁(1
Y→L₁(2
Z→L₁(3
Disp L₁

- 671
- 8
- 24