if (Tosend.indexOf("X")>0){
Serial.println("X axis has been selected");
Axis_val=(Tosend.indexOf("X"));
Serial.println(Axis_val);
}
It finds the X and returns the position as I require, unless the X is the first letter in the string.
How do I make it check the first character in the string? (Yes... I know strings are evil).
Specifying a start point (Tosend.indexOf("X",0)>0) didn't work either
indexOf()
Locates a character or String within another String. By default, searches from the beginning of the String, but can also start from a given index, allowing for the locating of all instances of the character or String.
Parameters
myString: a variable of type String.
val: the value to search for. Allowed data types: char, String. from: the index to start the search from.
Returns
The index of val within the String, or -1 if not found.
A string is a null terminated character array. A String is an object of the String class. Not to be pedantic, but they are not the same and the terms can not be used interchangeably.