LCD: erasing printed data? clearing specific fields?

howdy. thank you in advance for reading.

i have a 16x2 LCD screen that i have configured to print values being read from a pixart infrared sensor. the code prints the x and y values as read by the sensor. the resolution of this sensor is 1024 by 780.

let's say i do the following: read/print X values from the sensor starting at 0, then moving up to 10, then 100, and finally 1000. now, i move in reverse - back down to 0. problem: the numbers printed from the upper ranges (1000, etc) are not cleared when printing lower values.

i am unfamiliar with how to handle this, as this is my first experiment with an LCD screen. i don't want to clear the whole screen, i just want to print ONLY the digits being read from the sensor.

i hope this is clear. thank you for your time. nym

here is an example of what i am doing, with a commented out portion where i was trying to print blanks where otherwise there would be leftover numbers.

  int calibration[4];

int X1 = ircam.Blob1.X;
  int Y1 = ircam.Blob1.Y;
  if (result & BLOB1)
  {
    lcd.setCursor(9,0); 
    lcd.print("X: ");     
    lcd.setCursor(0,1);       
    lcd.print("Left: "); 
    lcd.setCursor(9,1); 
    lcd.print("Y: “);   
    lcd.setCursor(11,0);
//    lcd.rightToLeft();
//    if(X1 < 1000){lcd.print(” “);}
//    if(X1 <  100){lcd.print(”  “);}
//    if(X1 <  10){lcd.print(”  ");}
    lcd.print(X1); 
//    lcd.leftToRight();
    lcd.setCursor(11,1);
    lcd.print(Y1);

started figuring it out, but it seems like overkill to have to do if lesser thans for every degree.

  if (result & BLOB1)
  {
    lcd.setCursor(9,0);   
    lcd.print("X: ");       
    lcd.setCursor(9,1);   
    lcd.print("Y: ");     
    if(X1 < 1000){
      lcd.setCursor(13,0);
      lcd.print(" ");
    }
    else{
      lcd.setCursor(12,0);
    }
    lcd.print(X1);   
    lcd.setCursor(13,1);
    lcd.print(Y1);    
    lcd.leftToRight();

http://arduino.cc/forum/index.php/topic,105187.msg789058.html

thanks! i had searched, but didn't know how to phrase what i was looking for. apparently neither did the other guy.

If the search worked so well we would have had a lot less repeat questions. Simply asking a question is a learning process itself so you're welcome.