Nested variable/incrementing question

Hi, hopefully I am explaining this properly, I’m a beginner.

I have a script that prompts for a user input that asks for a tab number (starting with 0), then grabs from corresponding line in csv. I save this tab/csv line number as ${position_counter}.

On line 35, it reads from column 6 in the csv and converts the hh/mm text to seconds and saves as ${timeout_clock_${position_counter}}

However, what I really would want to do on line 35 is increment it by 1x if current runtime is greater than the current value, so that it continues adding indefinitely each time.

But I’m confused on how to check a variable before it exists and how to continue adding, but only once it hits the timeout. Should I be using an array? What is the best way to do this? Any help would be appreciated.

{
  "Name": "megaloop_test_example",
  "CreationDate": "2022-5-24",
  "Commands": [
    {
      "Command": "prompt",
      "Target": "Enter desired tab start position.",
      "Value": "position_counter",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return Number (${position_counter})",
      "Value": "position_counter",
      "Description": ""
    },
    {
      "Command": "csvReadArray",
      "Target": "loop_data_1.csv",
      "Value": "loop_data",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "var str = ${!RUNTIME}; var regex = (/^\\d*\\.?\\d+(?=s)/); var result = (regex.exec(str)); return Number (result)",
      "Value": "runtime",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": " ${loop_data[${position_counter}][3]}",
      "Value": "swap_status",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "var str = ${loop_data[${position_counter}][6]}; var regex1 = (/\\d+(?=h)/); var hours = (regex1.exec(str)); var regex2 = (/\\d+(?=m)/); var minutes = (regex2.exec(str)); var result = Number ((hours * 3600)+(minutes*60)); return result",
      "Value": "timeout_clock_${position_counter}",
      "Description": ""
    },
    {
      "Command": "bringBrowserToForeground",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "selectWindow",
      "Target": "tab=${position_counter}",
      "Value": "",
      "Description": ""
    }
  ]
}

You can “define” a variable by adding store | 0 | newVar to your macro.

How to continue adding, but only once it hits the timeout.

It sounds like “IF…” can help here.

Hi, do you have a small test case macro that we can run? (one that does not need e. g. an external CSV file)