Text object - text disappears on input change

 

I have the following code to display a text object on the chart:


int OnInit()
{
   ObjectCreate("asb_label", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("asb_label","Account Starting Balance",9, "Consolas", Black);
   ObjectSet("asb_label", OBJPROP_CORNER, 0);
   ObjectSet("asb_label", OBJPROP_XDISTANCE, horizontal_offset+10);
   ObjectSet("asb_label", OBJPROP_YDISTANCE, vertical_offset+10);
   ObjectCreate("asb_val", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("asb_val", rightAlign(starting_balance, 9, 2), 9, "Consolas", Black);
   ObjectSet("asb_val", OBJPROP_CORNER, 0);
   ObjectSet("asb_val", OBJPROP_XDISTANCE, horizontal_offset+335);
   ObjectSet("asb_val", OBJPROP_YDISTANCE, vertical_offset+10);

   return INIT_SUCCEEDED;
}

It works fine, but when I change an input variable, the text disappears. 

Probably something simple, but can anyone tell me why?

 
When you change an input variable, you go through a deInit/OnInit cycle. Did you delete your objects in deinit?
 
William Roeder #:
When you change an input variable, you go through a deInit/OnInit cycle. Did you delete your objects in deinit?


Tried a couple of things, but couldn't get them to work. So I have to delete all my text objects in deinit?


Can you give me an example?

 
rwh0965 #:


Tried a couple of things, but couldn't get them to work. So I have to delete all my text objects in deinit?


Can you give me an example?


I think I figured it out... just used:


      ObjectDelete("asb_label");
      ObjectDelete("asb_val");

Thanks