One of those 'passing strings' questions...
Hugh
Posts: 362
Sorry, another silly question...
I am trying to select a number of characters from a string (to be sent via simple_debug). The code is below but instead of extracting ten characters as intended I only receive four - do commas have an impact on the way strings are handled?
I thought I'd finally got my head around strings and things but apparently not.
Any help would be really appreciated.
Thanks
Hugh
I am trying to select a number of characters from a string (to be sent via simple_debug). The code is below but instead of extracting ten characters as intended I only receive four - do commas have an impact on the way strings are handled?
PUB BTSendGPSorFF (a, b, c, prefix) | indexC , scratch ' ~Scratchpad2~ is a global long, size "[50]" bytemove(@scratchpad2, string("$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230313,003.1,W*6A"), 50) ' Fill ~scratch~ with zeroes - anything we move to it subsequently will be zero-terminated, allowing us to treat it as a string bytefill(@scratch, 0, 50) 'Move ten bytes of ~scratchpad2~ into ~scratch~ bytemove(@scratch, @scratchpad2 + 20, 10) ' Send the prefix (string) passed in the call to this PUB. debug.str(prefix) ' Send ~scratch~ as a string. Because we filled ~scratch~ with zeroes it will be zero-terminated ' debug.str(@scratch) ' Send a CR debug.tx(13)
I thought I'd finally got my head around strings and things but apparently not.
Any help would be really appreciated.
Thanks
Hugh
Comments
There's not enough code posted to determine what "prefix" is doing or pointing to. Please post all your code!
You need a second byte array in the global space.
Thank you Jonny - that fixed it. :thumb:
With comments the top files is currently 1,356 lines so I thought better of posting all of it.
My name is Jon.
Sorry. I went by your user name rather than that in your sig.
I've been trying very hard to provide more gentle responses to posts. When requesting "All the code" and receiving a response of "It's too big" is actually insulting and shows a disregard for the folks trying to help.
Please realize, I had to fill in the logic gaps by make assumptions about the code base and your programming ability which I know nothing about. Given an incomplete view of the logic I had to come up with a guess and a thoughtful response. Please keep this in mind for future posts.
I thought that the comments in the code would be sufficient but my over-familiarity with the code meant that in trying to include only that immediately relevant I omitted some information with which anyone coming to it cold would not be familiar. Sorry
As will be apparent from the attached code, my 'programming ability' is 'not a lot'; I am possibly being over-ambitious with what is the third generation of the same idea.
Hugh
FFGPS202 - New board, tacho - Archive [Date 2014.05.26 Time 18.58].zip