| Author |
Message |
|
Dr Phil
Newbie

Joined: 17 Sep 2011 Posts: 35 Location: Sweden
|
Posted: 30 Sep 2011 07:15:24 am Post subject: |
|
|
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. |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 30 Sep 2011 07:19:18 am Post subject: |
|
|
it still doesn't work........ _________________



 |
|
| Back to top |
|
|
Dr Phil
Newbie

Joined: 17 Sep 2011 Posts: 35 Location: Sweden
|
Posted: 30 Sep 2011 07:22:35 am Post subject: |
|
|
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
|
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 30 Sep 2011 07:28:02 am Post subject: |
|
|
I didn't have the curled brackets! That's it! Thanks a lot! _________________



 |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 30 Sep 2011 09:04:01 am Post subject: |
|
|
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? _________________



 |
|
| Back to top |
|
|
Dr Phil
Newbie

Joined: 17 Sep 2011 Posts: 35 Location: Sweden
|
Posted: 30 Sep 2011 09:06:35 am Post subject: |
|
|
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. |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
|
| Back to top |
|
|
SirCmpwn

Coding Knight

Joined: 06 Feb 2010 Posts: 1477 Location: Colorado Springs
|
Posted: 30 Sep 2011 09:17:39 am Post subject: |
|
|
String manipulation with Axe is much more complicated than with TI-Basic. For beginners, pick another project. _________________ Drew "Sir Cmpwn" DeVault |
|
| Back to top |
|
|
Dr Phil
Newbie

Joined: 17 Sep 2011 Posts: 35 Location: Sweden
|
Posted: 30 Sep 2011 09:18:26 am Post subject: |
|
|
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. |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 30 Sep 2011 09:24:04 am Post subject: |
|
|
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 _________________



 |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2418 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 30 Sep 2011 02:10:58 pm Post subject: |
|
|
| 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'. _________________ -Ashbad |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 30 Sep 2011 03:26:30 pm Post subject: |
|
|
It works now....Sorry if I was confusing you guys....it truly is FARmore complicated than TI-BASIC.  _________________



 |
|
| Back to top |
|
|
Deep Thought

Expert

Joined: 11 Mar 2010 Posts: 739 Location: The Universe
|
Posted: 30 Sep 2011 03:30:55 pm Post subject: |
|
|
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. _________________
  |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2418 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 30 Sep 2011 03:33:14 pm Post subject: |
|
|
| 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. _________________ -Ashbad |
|
| Back to top |
|
|
Deep Thought

Expert

Joined: 11 Mar 2010 Posts: 739 Location: The Universe
|
Posted: 30 Sep 2011 03:35:42 pm Post subject: |
|
|
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  _________________
  |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
Posted: 01 Oct 2011 03:24:58 pm Post subject: |
|
|
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> _________________



 |
|
| Back to top |
|
|
Dr Phil
Newbie

Joined: 17 Sep 2011 Posts: 35 Location: Sweden
|
Posted: 01 Oct 2011 03:27:02 pm Post subject: |
|
|
| 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'
|
|
| Back to top |
|
|
aeTIos

Power User

Joined: 02 Nov 2010 Posts: 491
|
Posted: 01 Oct 2011 03:27:51 pm Post subject: |
|
|
3 lv gray: pt-on/change/off(HEX)^r
text to buffer:Fix 5: Text(x,y,text) :dispgraph |
|
| Back to top |
|
|
Ashbad

... I think redheaded girls are kind of cool

Joined: 01 Dec 2010 Posts: 2418 Location: Stomp Stomp Stomp, The Idiot Convention
|
Posted: 01 Oct 2011 03:32:09 pm Post subject: |
|
|
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. _________________ -Ashbad |
|
| Back to top |
|
|
Sorunome

Expert

Joined: 22 Feb 2011 Posts: 636 Location: Somewhere out there
|
|
| Back to top |
|
|
|