Using serial monitor to accept two inputs at a time using Serial.readStringUntil

i would like to input mobile phone number and text message at the same time in the serial monitor. the text message is fixed. it means that i set a character for example is letter ‘a’ that contains the codes for the message inside if else statements. the problem is when i input “+639XXXXXXXX, a” to serial monitor, the message is sent to the mobile phone number but without any message on it. here are the codes. Thanks for your help in advance!

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);

String myData = “”;
char command;
String myNumber = “”;

void setup()
{
Serial.begin(19200);
SIM900.begin(19200);
delay(1000); // give time to log on to network.

}

void loop (){

while(Serial.available ())
{
String command = “”;
myData = Serial.readStringUntil(’$’);
myData = myData.substring(0,myData.length());
//Serial.println(myData);
int index = myData.indexOf(",");
myNumber = myData.substring(0,index);
Serial.println(myNumber);
command = myData.substring(index+1,myData.length());
Serial.println(command);
}

SIM900.print(“AT+CMGF=1\r”);
delay(100);
SIM900.println(“AT + CMGS = “” + myNumber +”"");
delay(100);

if(command==‘a’)
{
SIM900.println(“The patient is hungry”); // Message to send
Serial.println(“The patient is hungry”);
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000);
}
else if(command==‘b’)
{
SIM900.println("The patient needs toilet assistance "); // Message to send
Serial.println("The patient needs toilet assistance ");
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000);

}
else if(command==‘c’)
{
SIM900.println(“The patient wants to adjust room temperature”); // Message to send
Serial.println(“The patient wants to adjust room temperature”);
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000);

}

else
{
}

//SIM900.print(outMessage);
//delay(1000);
// SIM900.write((char)26); //ctrl+z
// delay(1000);
}

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to separate the received data.

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R