The topic that you are asking about is parsing. Successful parsing requires a well defined input string, which you don't have.
When reading "X100" or "Y-345" from the serial port, how do you know when you have a complete packet? If, instead, you sent "<X100>" or "Y-345>", the start and end of packet markers (< and > respectively) clearly define when a packet has been received.
Search the forum for "started && ended" for an example of how to read packets from the serial port.
When you have a complete packet (in inData, for instance), you can copy the first character:
char one = inData;
Then, replace the first character with a space:
inData = ' ';
Then, you can convert inData to an integer:
int inVal = atoi(inData);
Then, between inVal and one, you know which direction to move, and how far.