I am building a project that refers to GCode for its data input.
I have managed to put together a sketch that reads the file one line at a time, and currently ignores anything that doesnt have a G in front of it!
Here is a snippet of the file (each line is a string)
G03 X128.058354 Y39.348978 Z-0.125000 I-1.307156 J-7.287508
G03 X127.286493 Y39.381414 Z-0.125000 I-0.772541 J-9.183613
G01 X126.899108 Y39.381414 Z-0.125000
G01 X126.899108 Y41.491541 Z-0.125000
G01 X135.489923 Y41.491541 Z-0.125000
G01 X135.489923 Y8.833634 Z-0.125000
G00 Z1.000000
So i want to populate three Floats with the appropriate values, X, Y and Z (I, and J are getting ignored for now)
As you can see, X is not necessarily the first number a parse would come across!
is there a way I can scan through the string to the X, if there is an X fill it with the float (and if not do something else with it perhaps), and then scan across to the Y, and then the Z?
I have found "IndexOf", but have not managed to work out how to grab the number which follows that position.
I suspect it might be a bit like this?:
int indexX = inputString.indexOf('X');
if (indexX > 1) int x = inputString[indexX].parseFloat();
except it isnt., or at least i get:
HelloWorld:81: error: request for member 'parseFloat' in 'inputString.String::operator[](((unsigned int)indexX))', which is of non-class type 'char'
any pointers as to which function would achieve what i need?
Thanks