the @ is killing me... [resolved]
I'm trying to convert a decimal number to hex. I got the simple numbers object and take my decimal number (I'm using 200108) and pass it through the code..
joe := 200108
steve:=num.ihex(joe,8)
Now, the result I am looking for somewhere should be $00030DAC
I know my variable steve here is a pointer to the string, so if I were to try to display this with tv_text (I'll call it term here because that's what everyone else calls it) should'nt I just say
term.hex(@steve,8)
or
term.str(@steve)
neither of them work for me. I get garbage on the screen. What am I doing wrong?
Post Edited (teddyp) : 4/10/2010 6:01:14 PM GMT
joe := 200108
steve:=num.ihex(joe,8)
Now, the result I am looking for somewhere should be $00030DAC
I know my variable steve here is a pointer to the string, so if I were to try to display this with tv_text (I'll call it term here because that's what everyone else calls it) should'nt I just say
term.hex(@steve,8)
or
term.str(@steve)
neither of them work for me. I get garbage on the screen. What am I doing wrong?
Post Edited (teddyp) : 4/10/2010 6:01:14 PM GMT
Comments
So, the code starts up full duplex serial and grabs the data from the gps...
the data is then loaded into the variables such as GPRMCa and GPGGAa. So, the data I want is located at GPRMCa[noparse][[/noparse]8] for example for the date. If I want to see the info on the screen, I use display.str(GPRMCa[noparse][[/noparse]8]) and BAM! I can see the date on my screen. Awesomeness. But I want to take that value for the date and convert it to hexadecimal. I have no idea where the value is. If I use display.hex(GPRMCa[noparse][[/noparse]8],8) I get say 00002662 out. That's telling me that it's a pointer to the data located in address $00002662, right? so if I did @GPRMCa[noparse][[/noparse]8] (which the compiler freaks out on, so I tried assigning another variable say steve:=GPRMCa[noparse][[/noparse]8] and then tried @steve) shouldn't it display the value at that address? Using the steve variable, I do display.hex(@steve,8) and I get another hex stream that just looks like an address like $0000266D. I used this example on purpose because it's usually only the last digit that is different and usually by about 10 or so. So, do I try display.hex(@@steve,8)? I get another value similar to the first two. I don't get why it can send out the value in string format, but try decimal or hex and I get these results. I'm currently trying to just see the data so I then use numbers or simple numbers to convert it to a hex string to be tooled with. When the GPS does not have a signal, the default date it outputs is 200108 or $30DAC. So, shouldn't one of those locations have $30DAC in it? It's driving me insane.
The @ does the opposite of what you want.
for the first part, I get the default date out (200108) but for the second part, I get 30303200 not essentially what I was expecting, but I think it may be the ascii for the data backwards, as in $30=0 and $32 =2 with 00 being EOT.
so, if thats the case, then backwards it would be EOT 200 being half of the string displayed. which also means the second half is in the memory location either immediately after or before this one. Any idea how I go about accessing that? I was under the impression that I could just do something like GPRMCa[noparse][[/noparse]8]++. or perhaps a different offset hrm...
as per the language reference on page 130, I just did
now, steve =002 and mike =801, or the string 200108 backwards. Awesome! Thanks for the help everyone!
I know it says x1 in there, its just a 1, the bb code stripped it out the first time.
Post Edited (teddyp) : 4/10/2010 6:15:03 PM GMT