I have the following loop code:
for ( i = 0; i <= 59; i++)
M = H + i;
if(M == FS)
Ready = StringConcatenate( IntegerToString(CH),":", IntegerToString(i));
TL = StringToTime(Ready) ;
//---------- Drawing time line--------------//
Obj_Name="Tk"; // Name of the object
ObjectCreate(Obj_Name,OBJ_VLINE,0,TL,0);// Create object..
ObjectSet(Obj_Name,OBJPROP_COLOR, DarkOrange); // ..and its color,..
ObjectSet(Obj_Name,OBJPROP_STYLE, STYLE_DOT); // ..and style..
When I run this program. For loop is working for first instance. For example when i = 6, M== FS condition satisfies, it draws the time line & then its gone out of the loop & again starting the loop from i = 0.
I don't want that, I want it to start the loop now from i+1 after the first instance i.e in above example. Now loop should start after 6, i.e from 7.
How to do that?
Any help will be appreciated.
string Obj_Name="Tk" + i; // Name of the object
I'm not sure what you are trying to achieve
if you want to increment the starting point each time a for loop is called
static int counter=0;
for(i=counter; i<=59; i++)
that will do it, the last 2 lines set counter back to 0 when the maximum is reached
In your code, you create an object called "Tk"
Once an object has been created, you cannot create another object with the same name. So if you want multiple lines, give a new name each time. If you just want a single line in a new position, use ObjectMove
Thank you both for pointing out the problem.
Thank you qjol , your code worked!
I updated the code.
Obj_Name= IntegerToString(i) + "Tk" ;
But when i tried to delete the those object at deinit() with the following code. Objects are not getting deleted.
How to delete those object when i remove the indicator?
Thank you for such a quick reply.
Previously I added "_" before as Object was naming like 4Tk etc etc.
I understood my mistake.
Now its working perfectly.