I'm no expert, but it should be quite obvious that your program isn't working. The "" command returns a pointer to the place where your string is saved, it does not return the values of the characters in the string.

To get your program to work, either use the byte value of the letter (A=65, B=66 and so on) or use {"E"}. There might be a smarter way, but not what I know of.
it still doesn't work........
Then you are typing something wrong. This code works perfectly for me:


Code:
.TST
"HELLO WORLD"→Str1
Text(0,0,inData({"W"},Str1)▶Dec)
Pause 1000
I didn't have the curled brackets! That's it! Thanks a lot!
I got another question...... Can you make somehow If Str1="T"? That doesn't work...... if you put curly brackets around "T" it still doesn't work. Can you do that somehow?
What is it you want to check? If the first character in Str1 is "T"? Then I think it'll be:
Code:
If {Str1}={"T"}
but I haven't tested it.
That works, thanks. I don't really get when you have to use curled brackets and when not. Can someone please explain me?
EDIT: oh no, it doesn't work! I have
Code:
:"Blah Blah Blah Blah Blah Blah"->M
:16->D
:Repeat {L1}={" "}
:Copy(M+D,L1,1
:D-1->D
:End
:Copy(M,L1,D
:Text(1,1,L1

It displays Blah Blah Blah B but it should display Blah Blah Blah.
String manipulation with Axe is much more complicated than with TI-Basic. For beginners, pick another project.
You have to use curly brackets when you are dereferencing a pointer.
For example, when you make a string like this:
Code:
"Hello world"→Str1
then Str1 is a pointer to a part of the RAM where the actual data is stored. That means Str1 is just a number, the addressnumber of the memory location where your string is stored.

If you do

Code:
If Str1="T"
then you'll be comparing two addresses, not the data at the addresses. The curly brackets dereferences the pointer, (grabbing the data the pointer points to) so that you are comparing data instead of addresses.

If you are not understanding pointers, try to read some tutorial on the net. Pointers is quite common in most languages, especially low-level languages.
Could you maybe please just tell me how I would have to do that code, because it is the only string manipulation I think I need for my program? Or could you maybe please link a tutorial, I couldn't find one on omnimaga. :S
Dr Phil wrote:
What is it you want to check? If the first character in Str1 is "T"? Then I think it'll be:
Code:
If {Str1}={"T"}
but I haven't tested it.


I can tell you haven't tested it. That wouldn't work; you're comparing the pointer of a one-char string to the value of the first byte of a string. If you want to directly test against char values, use single quotations, like 'T'.
It works now....Sorry if I was confusing you guys....it truly is FARmore complicated than TI-BASIC. Smile
Axe 1.0.0 and above have an Equ>String() command that does string comparison. Look in the updated Axe Commands list for more information.
Deep Thought wrote:
Axe 1.0.0 and above have an Equ>String() command that does string comparison. Look in the updated Axe Commands list for more information.


Testing for one character puts it to shame. For testing one character like he was showing, checking the first pointed to value against a constant char value is a *lot* more optimized and sane.
Oh, didn't notice it was a single char. Yeah, testing the char value is a lot better than using the new routine. Ignore my last post Smile
Sorry for this totally noob question.......but I somehow got a black out on one thing, so could someone please just post a example code of it: Drawing 3-level gray scale things to screen and drawing text to screen. it somehow doesn't work if I do <elements> <text>
Ashbad wrote:
Dr Phil wrote:
What is it you want to check? If the first character in Str1 is "T"? Then I think it'll be:
Code:
If {Str1}={"T"}
but I haven't tested it.


I can tell you haven't tested it. That wouldn't work; you're comparing the pointer of a one-char string to the value of the first byte of a string. If you want to directly test against char values, use single quotations, like 'T'.

Err.. Ashbad, you are the one who has clearly not tested it, it does work as intended. Curly brackets dereferences a pointer. My code would work, and it would be just slightly larger than the correct:

Code:
If {Str1}='T'
3 lv gray: pt-on/change/off(HEX)^r
text to buffer:Fix 5: Text(x,y,text) :dispgraph
Of course I would never test it. I stopped using Axe a while ago and am proud to have done so. I do see though now, you were correct before; I overlooked the curly brackets, I was on an iPad and with small text things can be hard to see. It isn't however still correct; that method is rather horrible, since it adds 2 bytes to your program each time you test it that way, and many more bytes/cycles for the routine since it has to dereference *and then* compare the value (and make sure that both values are of the same bit-length int size) instead of just comparing to an already-correctly-sized constant value.
aeTIos wrote:
3 lv gray: pt-on/change/off(HEX)^r
text to buffer:Fix 5: Text(x,y,text) :dispgraph

I have

Code:
:   *some 3-level Grayscale elements*
:Fix 5
:text, 5,5,"Test"
:DispGraph
:Repeat getKey
:DispGraph^r       //radian "r"
:End

And it doesn't display the text....
  
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
» Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 10, 11, 12  Next
» View previous topic :: View next topic  
Page 7 of 12
» 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