A task with buttons ! - page 8

 
Also an option. Only you don't need to create them on every tick.
 
static string name=NULL;
for(int i=0;i<10;i++)
  {
   bool But=ObjectGetInteger(0,(string)i,OBJPROP_STATE);
   if(but && name!=(string)i)
     {
      ObjectSetInteger(0,name,OBJPROP_STATE,false);
      name=(string)i;
     }
  }
If the button names are not numbers, then put the names in an array.
 
Rorschach:
If button names are not numbers, then the names will be placed in an array.
The previous button remains pressed until the next cycle call ...
 

I don't know if this is the right approach, but it solves the problem

static string name=NULL;
for(int i=0;i<10;i++)
  {
   bool But=ObjectGetInteger(0,(string)i,OBJPROP_STATE);
   if(but && name!=(string)i)
     {
      ObjectSetInteger(0,name,OBJPROP_STATE,false);
      name=(string)i;
      i=0;
      }
  }
 
static string name=NULL;
for(int i=0;i<10;i++)
  {
   bool But=ObjectGetInteger(0,(string)i,OBJPROP_STATE);
   if(But && name!=(string)i)
     {
      ObjectSetInteger(0,name,OBJPROP_STATE,false);
      name=(string)i;
      ChartRedraw();
      break;
     }
  } 
Maybe so, haven't tried it.
 
Rorschach:
Maybe so, I haven't tried it.

I decided a little differently

static string name=NULL;
for(int i=0;i<10;i++)
  {
   bool But=ObjectGetInteger(0,(string)i,OBJPROP_STATE);
   if(but && name!=(string)i)
     {
      ObjectSetInteger(0,name,OBJPROP_STATE,false);
      name=(string)i;
      i=0;
      }
  }

I didn't check your last variant, but I suspect that if button index 10 is pressed and then index 9 is pressed, then index 10 won't be pressed because the loop is broken at index 9...