parseInt reversing values

I’m working on building a simple bluetooth robot.
I have it connecting and things seemed to be going GREAT until I realized that parseInt is reversing my values when I put it into a function call. (Code attached below)

If I send an input of right turn “180,0”

When I use:
Left = BLE.parseInt();
Right = BLE.parseInt();
MotorSet(Left,Right);
It outputs “Motors: Left 180, Right 0” and turns right.

When I use:
MotorSet(BLE.parseInt(),BLE.parseInt());
It outputs “Motors: Left 0, Right 180” and turns left.

I know I can just switch my values somewhere, but I would like to know WHY it reverses when in the function call.

Also, does anyone know how to test if my bluetooth module becomes disconnected?
That’s my next obstacle.

/*   Control PWM motors with commands over BLE with HM-10 module
 *   
 *   Corey Wilkes
 *   July 2015
 *   
 *   Expected command syntax LeftMotorSpeed,RightMotorSpeed "90,90"
 *   Motor speeds are based on PWM servo. 0=Full Reverse, 90=Stop, 180=Full Forward
 */

#include <SoftwareSerial.h>
#include <Servo.h>

SoftwareSerial BLE(13, 12); //BLE(TxPin, RxPin)
Servo LeftMotor;
Servo RightMotor;

void setup() {
  Serial.begin(9600);   // Begin the Serial Monitor connection at 9600bps
  BLE.begin(57600);     // Begin the BLE connection at 57600bps
  BLE.setTimeout(10);   // Set timeout from default of 1000ms to 10ms for faster response

  LeftMotor.attach(3);    //Set Left Motor Pin
  RightMotor.attach(5);   //Set Right Motor Pin
  
  MotorSet(90,90);        //Set motors to STOP
}

void loop() {
  if (BLE.available())  {  // Read from HM-10 and parse motor speeds
    MotorSet(BLE.parseInt(),BLE.parseInt());
    BLE.flush();
  }

//  if (SignalLostTest?????)   //Test for signal loss
//    MotorSet(90,90);      //Set motors to STOP
}

void MotorSet(int LeftMotorSpeed, int RightMotorSpeed) {
  if(LeftMotorSpeed > 86 &&  LeftMotorSpeed < 94)   //Set left motor dead zone
    LeftMotorSpeed = 90;
  if(RightMotorSpeed > 86 &&  RightMotorSpeed < 94) //Set right motor dead zone
    RightMotorSpeed = 90;
  
  Serial.print("Motors: Left ");
  Serial.print(LeftMotorSpeed);   //Print values to Serial Monitor
  Serial.print(", Right ");
  Serial.println(RightMotorSpeed);
  
  LeftMotor.write(LeftMotorSpeed);      //Set Left speed
  RightMotor.write(RightMotorSpeed);    //Set Right speed
}
MotorSet(BLE.parseInt(),BLE.parseInt());

The order in which the function arguments are evaluated is undefined. (Or unspecified).

This should work better:

int Left = BLE.parseInt();
int Right = BLE.parseInt();
MotorSet (Left, Right);

… which is what you already realize works.

That forces the evaluation order.

See, for example: http://stackoverflow.com/questions/2934904/order-of-evaluation-in-c-function-parameters

Thanks!
That’s really helpful.