deactivate un-used zeros

I have a script which counts with textures for example 123 would assign the texture 1,2 and 3 to be rendered, but when I only have 1 digit like (5)the others are set to zero making it look like (500)…so how can i disable the zeros until they become meaningful like in numbers (20) or (560)…

     // varibles begin // 
var TotalPoints:int; // this variable is edited externaly and shows howmany points we have 

//***************************
var digit1:int;
var digit2:int; // all these are to store the integers 
var digit3:int;
var digit4:int;
//***************************

var CoinsTextTexture: Texture; // texture section this is for the text "coins"

var numbers : Texture2D[];// array of  images of numbers 0-9

//***************************

       //end of variables//
 


 function Update(){
    
    var s:String = TotalPoints.ToString();

 
     digit1 = int.Parse(""+s[0]);
     digit2 = int.Parse(""+s[1]);
     digit3 = int.Parse(""+s[2]);
     digit4 = int.Parse(""+s[3]);
   }
     
   function OnGUI(){
   
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.75,70,50), CoinsTextTexture);
   
     
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.85,100,100), numbers[digit1]);
    
    
     GUI.DrawTexture(Rect(Screen.width*0.04,Screen.height*0.85,100,100), numbers[digit2]);
	 
	      
     
     GUI.DrawTexture(Rect(Screen.width*0.08,Screen.height*0.85,100,100), numbers[digit3]);
     
     
     GUI.DrawTexture(Rect(Screen.width*0.12,Screen.height*0.85,100,100), numbers[digit4]);

}

After a long struggle i finally got it … This is not the most efficient way but it worked. If any one has any ideas of how i can make it better or if I’m doing this wrong please tell me. here is the code in case someone has this problem! :]

         // varibles begin // 
var TotalPoints:int; // this variable is edited externaly and shows howmany points we have 

//***************************
var digit1:int;
var digit2:int; // all these are to store the intigers 
var digit3:int;
var digit4:int;
//***************************

var s: String; //this holds the current number

//***************************
var CoinsTextTexture: Texture; // texture section this is for the text "coins"
var numbers : Texture2D[];// array of  images of numbers 0-9

//****************************
       //end of variables//
 

 function Update(){
    s = TotalPoints.ToString();
    var numberInt: int;
    
    numberInt = int.Parse(s);
 
     digit1 = int.Parse(""+s[0]);
     if(numberInt>9){             // I added this condition becuase i got the index is out of range error..
     digit2 = int.Parse(""+s[1]);
     }if(numberInt>99){
     digit3 = int.Parse(""+s[2]);
     }if(numberInt>999){
     digit4 = int.Parse(""+s[3]);
     }
   }
     
   function OnGUI(){
     
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.75,70,50), CoinsTextTexture);// random texture display 
   
                                         //Digit 1
    //**************************************************************************************************************** 
     
       if(s.Length==1){ // if s has 1 digit  ************************************
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.85,100,100), numbers[digit1]);
      
      }
      
      
      
                                          //Digit 2
   //**************************************************************************************************************** 
     
       if(s.Length==2){ // if s has 2 digits ****************************
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.85,100,100), numbers[digit1]);
     GUI.DrawTexture(Rect(Screen.width*0.04,Screen.height*0.85,100,100), numbers[digit2]);
	   
	   }
	   
	   
	                                      //Digit 3
   //**************************************************************************************************************** 
	      
	   if(s.Length==3){ // if s has 3 digits ****************************
	 GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.85,100,100), numbers[digit1]);
     GUI.DrawTexture(Rect(Screen.width*0.04,Screen.height*0.85,100,100), numbers[digit2]);
     GUI.DrawTexture(Rect(Screen.width*0.08,Screen.height*0.85,100,100), numbers[digit3]);
	   
	   }
	  
                                          //Digit 4 
   //**************************************************************************************************************** 
      
      if(s.Length==4){ // if s has 4 digits ****************************
     GUI.DrawTexture(Rect(Screen.width*0.0,Screen.height*0.85,100,100), numbers[digit1]);
     GUI.DrawTexture(Rect(Screen.width*0.04,Screen.height*0.85,100,100), numbers[digit2]);
     GUI.DrawTexture(Rect(Screen.width*0.08,Screen.height*0.85,100,100), numbers[digit3]);
     GUI.DrawTexture(Rect(Screen.width*0.12,Screen.height*0.85,100,100), numbers[digit4]);
	   
	   }	  
  
}

There’s a much easier solution. Just use your original code and change line #23 to:

    var s:String = TotalPoints.ToString("D4");