C# Component - RunCounter needed

Hi everyone,
I´m a little stuck right now. I need an intenger which stays alive while going through different lists. It is my goal to change the path in the following itereation without the need of going into the tree structure (don´t like it very much, because input trees can change).

This is my current “TestCode” to get an int of the currentRun, but the script always runs through every peace of inputItem:

  private void RunScript(bool reset, bool run, List<int> inputList, int listLength, ref object A)
  {
    if (reset)
    {
      n = 0;
      collection.Clear();
    }
    else if(run){

      collection.AddRange(inputList);

      if(n < listLength)
      {
        Component.ExpireSolution(true);
      }

      n++;
    }
    A = collection;
  }

  // <Custom additional code> 

  List<int> collection = new List<int>();
  int n = 0;
  // </Custom additional code> 
}

When the index is working I want to bring objects from a list into a new Structure depending on a group dependency:

for(int x = 0; x < curves.Count ; x++)
    {
      curveList.Add(curves[x], new GH_Path(0, groupDictionary[x]));
    }

Thanks for your help :slight_smile:

Quick tip, you can surround your code blocks with triple ticks to make them look like code:

```
curveList.Add(curves[x], new GH_Path(0, groupDictionary[x]));
```

yields:

curveList.Add(curves[x], new GH_Path(0, groupDictionary[x]));
1 Like