Help with strings/hex? [solved]
teddyp
Posts: 14
So, what I have is the date in the format MMDDYY in string format. I want to print it as MM/DD/YY to the serial terminal. I have tried string and string2 with horrible amounts of fail. If I have the date in a variable called "date" how can I format this? Using some code...
but, if I try to use the terminal and...
I get crazy characters on the screen
I tried to create a temp string. from what I see in memory date is preceded and superseded with 00 or EOT. so, if I...
I get all 0's when I print it out to the terminal and crazyness if I tried to print the string. What am I doing wrong here? Why am I having such a hard time with something so simple? Thanks in advance anyone.
Post Edited (teddyp) : 4/19/2010 10:04:42 PM GMT
pst.str(date) 'prints out the date 041910 for today pst.str(string(13)) 'CR pst.dec(strsize(date)) 'prints out decimal 6 (length of the date string) pst.str(string(13)) 'CR repeat k from 0 to strsize(date) - 1 'from 0 to 5 pst.hex(byte[noparse][[/noparse]date][noparse][[/noparse]k],2) 'I get 30 34 31 39 31 30 all hex good. pst.str(string(13))
but, if I try to use the terminal and...
pst.str(byte[noparse][[/noparse]date][noparse][[/noparse]0]) pst.str(byte[noparse][[/noparse]date][noparse][[/noparse] 1 ])
I get crazy characters on the screen
I tried to create a temp string. from what I see in memory date is preceded and superseded with 00 or EOT. so, if I...
byte[noparse][[/noparse]@MyDate][noparse][[/noparse]0] :=$00 byte[noparse][[/noparse]@MyDate][noparse][[/noparse] 1 ] := byte[noparse][[/noparse]date][noparse][[/noparse]0] byte[noparse][[/noparse]@MyDate][noparse][[/noparse] 2 ] := byte[noparse][[/noparse]date] byte[noparse][[/noparse]@MyDate][noparse][[/noparse] 3 ] := $00 pst.hex(MyDate,8)
I get all 0's when I print it out to the terminal and crazyness if I tried to print the string. What am I doing wrong here? Why am I having such a hard time with something so simple? Thanks in advance anyone.
Post Edited (teddyp) : 4/19/2010 10:04:42 PM GMT
Comments
The problem with your code is that you call pst.str without giving an address. str function want's an address and not values. And the address must point to a byte array which has a $00 as a string-end character.
The tx-function is fine with the character value, so you can use this to print exactly one character.
Post Edited (MagIO2) : 4/19/2010 9:40:06 PM GMT
Thanks again for the help! I wish I would've found that wiki earlier
Simple_Serial and FullDuplexSerial both have the function tx and I'm pretty sure that any serial interface has something similar. What exactly is PST?