JPfowl wrote:
Let's say I have some text and some integer (like an answer stored into x) and I want to join those so I can output them together. How could I do so? Is it possible with strings? (I want to join them to make it easier to output if I have multiple groups of text and integer).
If you're using Text() to output them, you can just do so without converting them.
Code:
Text(0,0,"FOO: ",42
will print "FOO: 42" at the top left corner of the graph screen.

But if you really want to concatenate them, you can use the routine Raylin linked to.
Ok, thanks Raylin, but how would I add that integer string (stored into string 2) to my text in string 1?

Code:

:Str1+Str2->Str1

Like that?
Yes, + puts two strings together.
Yep yep.

If the integer is already in a string, that will do it for you.
Deep Thought wrote:
JPfowl wrote:
Let's say I have some text and some integer (like an answer stored into x) and I want to join those so I can output them together. How could I do so? Is it possible with strings? (I want to join them to make it easier to output if I have multiple groups of text and integer).
If you're using Text() to output them, you can just do so without converting them.
Code:
Text(0,0,"FOO: ",42
will print "FOO: 42" at the top left corner of the graph screen.

But if you really want to concatenate them, you can use the routine Raylin linked to.


Would that work for multiple groups of text and numbers?
In regards to the Text(0,0,"FOO: ",42, yes.
You can add as many arguments as you want onto the command. They will all display on one line.
/\yup!
there isn't even a noticeable decrease in speed
JPfowl wrote:
Would that work for multiple groups of text and numbers?
As many as you want, as Raylin said. Anything after the two position arguments is something to be displayed.

And yeah, the routine for converting strings to numbers is pretty hackish and relatively slow (it involves finding a best-fit line). That's why I suggested just using Text() to display them all unless there's some specific reason you need it all to be one string.
I just wanted a way for me to display text and numbers. (Writing some basic, very basic, programs like equation of a line and output command isn't the best for that.
The Text command outputs the text to the graph screen doesn't it?
Deep Thought wrote:
JPfowl wrote:
Would that work for multiple groups of text and numbers?
As many as you want, as Raylin said. Anything after the two position arguments is something to be displayed.

And yeah, the routine for converting strings to numbers is pretty hackish and relatively slow (it involves finding a best-fit line). That's why I suggested just using Text() to display them all unless there's some specific reason you need it all to be one string.


>best-fit line

Click my link. Where do you see this line?

@JPfowl: Yes, it does.
Sorry, I assumed you were linking to the other one (the one that works for decimals). Guess I should check first next time Razz
I have a code specific problem now. This is a slightly modified code to loop a string that can be edited as it loops. When the 23 key is pressed (del), only the last letter from line four is deleted, not the last letter from all lines. Can you see the error?

Program:LOOPER

Code:

:" →Str2
:1→W
:1→Q
:ClrHome
:While W=1
:ClrHome
:getKey→K
:Output(1,1,Str2
:Output(2,1,Str2
:Output(3,1,Str2
:Output(4,1,Str2
:Output(5,1,Str2
:Output(6,1,Str2
:Output(7,1,Str2
:Output(8,1,Str2
:If K=23 and 1-length(Str2
:Then
:Output(1,Q,"
:Output(2,Q,"
:Output(3,Q,"
:Output(4,Q,"
:Output(5,Q,"
:Output(6,Q,"
:Output(7,Q,"
:Output(8,Q,"
:Q-1→Q
:sub(Str2,1,length(Str2)-1→Str2
:End
:If ((K>40 and K<44) or (K>50 and K<56) or (K>60 and K<66) or (K>70 and K<76) or (K>80 and K<86) or (K>90 and K<95)) and length(Str2)<16
:Then
:Str2+sub("ABC       DEFGH     IJKLM     NOPQR     STUVW     XYZθ",K-40,1)→Str2
:Q+1→Q
:End
:If ((K>10 and K<16) or (K>20 and K<23) or (K>23 and K<27) or (K>30 and K<35) or (K>93 and K<96) or (K>101 and K<105))
:Stop
:If K=105:Then
:If length(Str2)>1
:sub(Str2,2,length(Str2)-1)→Str2
:If length(Str2)=1
:Return
:End
:End


Here is the second program I was working on, some very simple algebra programs. I can seem to get the text commands to work. How tall are the letters in pixels? My text commands have each text command based on 10 (e.g. 10,20,30...). How can I shorten that so that they don't overlap?

Program:Basic

Code:
:ClrHome
:CoordOff
:GridOff
:AxesOff
:LabelOff
:ExprOff
:Output(1,1,"Program made by:"
:Output(2,1,"Josh Pham"
:Output(6,1,"Contact"
:Output(7,1,"JPfowl@gmail.com"
:Output(8,1,"For help"
:Pause
:Lbl TT
:ClrHome
:Fix 2
:Menu("Sub Program?","Pyth. Solver",PS,"2-Pt. Solver",TS,"Quad. Solver",QS,"FOIL",FF,"Exit",EE)
:Lbl PS
:ClrHome
:Menu("A{^2}+B{^2}=C{^2} Solve4?","A",PA,"B",PB,"C",PC,"Menu",TT
:Lbl PA
:ClrHome
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt B
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt C
:ClrHome
:sqrt(C{^2}-B{^2})→A
:Text(80,1,"A{^2}+B{^2}=C{^2}"
:Text(10,1,"A=",A
:Pause
:Goto PS
:Lbl PB
:ClrHome
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt A
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt C
:ClrHome
:sqrt(C{^2}-A{^2})→B
:Text(80,1,"A{^2}+B{^2}=C{^2}"
:Text(10,1,"B=",B
:Pause
:Goto PS
:Lbl PC
:ClrHome
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt A
:Output(8,1,"A{^2}+B{^2}=C{^2}"
:Prompt B
:ClrHome
:sqrt(A{^2}+B{^2})→C
:Text(80,1,"A{^2}+B{^2}=C{^2}"
:Text(10,1,"C=",C
:Pause
:Goto PS
:Lbl QS
:ClrHome
:Output(8,1,"Ax{^2}+Bx+C"
:Prompt A
:Output(8,1,"Ax{^2}+Bx+C"
:Prompt B
:Output(8,1,"Ax{^2}+Bx+C"
:Prompt C
:ClrHome
:Text(80,1,"Ax{^2}+Bx+C"
:Text(10,1,"x=",X
:Text(20,1,"x=",Y
:(({-}B+sqrt(B{^2}-4AC))/(2A))→X
:(({-}B-sqrt(B{^2}-4AC))/(2A))→Y
:Pause
:Goto TT
:Lbl TS
:ClrHome
:Output(8,1,"(X,Y);(A,B)"
:Prompt A
:Output(8,1,"(X,Y);(A,B)"
:Prompt B
:Output(8,1,"(X,Y);(A,B)"
:Prompt X
:Output(8,1,"(X,Y);(A,B)"
:Prompt Y
:((Y-B)/(X-A))→S
:(Y-SX)→B
:((A+X)/2)→C
:((B+Y)/2)→D
:sqrt(((A+X){^2}+(B+Y){^2}))→M
:ClrHome
:Text(10,1,"(A,B);C,D)"
:Text(20,1,"Equ. of a Line:"
:Text(30,1,"y=",S,"x+",B
:Text(40,1,"Mid Pt.:"
:Text(50,1,"(,C,",",D,")"
:Text(60,1,"Distance:",M
:Pause
:Goto TT
:Lbl FF
:ClrHome
:Output(8,1,"(Ax+B)(Cx+D)"
:Prompt A
:Output(8,1,"(Ax+B)(Cx+D)"
:Prompt B
:Output(8,1,"(Ax+B)(Cx+D)"
:Prompt C
:Output(8,1,"(Ax+B)(Cx+D)"
:Prompt D
:ClrHome
:(AB)→M
:(BC+AD)→N
:(BD)→O
:ClrHome
:Text(10,1,"(Ax+B)(Cx+D)"
:Text(20,1,M,"x{^2}"+,N,"x+",O
:Pause
:Goto TT
:Lbl EE
:Float
:CoordOn
:GridOff
:AxesOn
:LabelOn
:ExprOn
:Stop
On homescreen letters are 7px tall and on graph screen with the small font they are 5px tall.
If you would like some code help, a lot of those programs I have made before and I am in the process of rewriting and optimizing. If you would like optimizing tricks or just some code to look over to learn from, just let me know and I will help you out. As will a lot of other people from here.
Part of these I am doing for a class, the other I am doing as a self learning venture/ for fun.
OK well if you have any question, let us know. I have a lot of code that could help, but I would have to explain quite a bit of it. it is fairly complex.
  
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 2 of 2
» 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