SoftwareSerial + Serial.printlen() not working properly I want to read a SMS message , find it's length and do some "substring();" operation on received SMS. My last two(2) statements do not work . How can I get correct answers? What are correct codes ?  

#include &lt;SoftwareSerial.h&gt;
#include &lt;string.h&gt; 
#include &lt;ctype.h&gt;
SoftwareSerial mySerial(2,3);

String TelephoneNumberText="";

void setup()
{
  pinMode(13, OUTPUT); 
  digitalWrite(13, LOW); 

  mySerial.begin(9600);   
  Serial.begin(9600);                
  delay(100);  

  mySerial.println("AT+CMGF=1\r");    //Sets the GSM Module in Text Mode 
  delay(500);  
}

void loop()   
{

 while(mySerial.available())
  {
   char s;
   s = mySerial.read(); 
   TelephoneNumberText = TelephoneNumberText + s;                     
   } 


 Serial.println(TelephoneNumberText);           // this statement works

 Serial.println(TelephoneNumberText.length());  // this statement dose not works

 Serial.println(TelephoneNumberText.substring(0,3));// this statement dose not works



} // end loop
Are you sure a string like this can be used?

Better anyway to not each time let a dynamic string be created, but use a fixed string e.g.

char TelephoneNumberText[16]; 


Set the length of the max number, and change other string functions accordingly.