Question about "ObjectCreate"

 
Here is my code. I want that every times I change the property "line", the old horizontal line will be deleted and the new one will be created. How to change my code to make that happen? One more thing: Sometime I start my code with value in property "line" it wont draw a line, and sometime does. And when I change the value of property "line" it wont create a new line. Does any one know why? THANK YOU SO MUCH FOR YOUR TIME!!!   
extern double line=0;



int start(){

ObjectCreate("LINE",OBJ_HLINE,0,iTime(NULL,0,0),line,0,0,0,0);

} 


 
Pain : I want that every times I change the property "line", the old horizontal line will be deleted and the new one will be created. when I change the value of property "line" it wont create a new line.
  1. ObjectCreate creates a new line. Once it exists your create fails and the old one still exists. This you would have learned that had you checked the return code. What are Function return values ? How do I use them ? - MQL4 forum
  2. Choice A) ObjectDelete the original and create a new one.
  3. Choice B) move it to the new position
    void     HLine(string name, double P0, color clr){    #define iCB         0
       if      ( ObjectMove(name, 0, Time[iCB], P0) ){}   #define WINDOW_MAIN 0
       else  if( !ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[iCB], P0) )
          AlertMe( "ObjectCreate(",name,",HLINE) failed: ", GetLastError() );
       if( !ObjectSet(name, OBJPROP_COLOR, clr) )            // Allow color change
          AlertMe( "ObjectSet(", name, ",color) [1] failed: ", GetLastError() );
       if( !ObjectSetText(name, PriceToStr(P0), 10) )
          AlertMe( "ObjectSetText(",name,") [3] failed: ", GetLastError() );
    }
    string   PriceToStr(double p){   return( DoubleToStr(p, Digits) );            }
  4. iTime(NULL,0,0)
    Why are you using an expensive function call instead of the simplifier, predefined Time[0]
Reason: