Hi Mike, yeah I figured I could do some string manipulation there - I'm so used to PHP that getting my brain working with C++ again is a little tricky, haha.
Here's the code: szBuffer is: char;
Then I use a trace to echo the value of comData into the output log...Code:
comData = szBuffer;
I've had minimal success with .substr and .find... Might have to modify the Serial port code a little more...
Ok, getting a little bit further here, but these string functions aren't working... not sure what's wrong :(
Here's what's up.
I'm reading the com-port data, and storing that into a buffer.
I strip the buffer of all unnecessary data and store that in a String that looks like this:
and comData contains: "X:0.59Y:0.42Z:-171.80"
So far so good... now, I need to extract the positions of X: , Y: and Z:
So I tried doing it like this:
Which I would expect to return: 0, 6, 12Code:
int xpos, ypos, zpos; //(Also tried with size_t, sorry - I'm a noob)
xpos = comData.find("X:");
ypos = comData.find("Y:");
zpos = comData.find("Z:");
But nope, C++ has stumped me again - nothing gets returned :(
Please debug by single-stepping through the pertinent code, and confirm that all variables contain what you think they contain.
Also, reiterating what VictorN said, define "nothing gets returned". The std::string::find function always returns something. Even if the requested content is not found, the member value npos (equal to -1) is returned.
Ah yes, sorry about that - I changed the output to contain the X,Y,Z values - and tried using find() ... still ran in to some problems, but I think I've got it figured out.
Thanks for the help! :thumb: