Problem to create nested loops

I have tried to create a nested loop to acquire the data from a website. As I have shown below, due to the problem with nested loops, I have used normal coding instead of nested one. Can anyone help me with the corresponding nested version. PS: I don’t have commands like endwhile…, whilev1_depreceated… and many more , please can you explain how to solve this issue as well?

Here is the simple code I have used instead of two nested loops:

{
  "CreationDate": "2021-5-25",
  "Commands": [
    {
      "Command": "open",
      "Target": "http://www.nepalstock.com.np/main/floorsheet/index/${!loop}/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "1",
      "Value": "nepse",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${nepse} <= 20)",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[3]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[4]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[5]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[6]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[7]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[8]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[9]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[10]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[11]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[12]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[13]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[14]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[15]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[16]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[17]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[18]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[19]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[20]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[21]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[3]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[4]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[5]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[6]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[7]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[22]/td[8]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "csvSave",
      "Target": "nepsedata",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "${nepse}+1",
      "Value": "nepse",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

As you can see I have to store text from tr[3-22] and td[3-8] within each tr mentioned above. Furthermore, I will loop the code for thousand of times to collect data from the multiple pages available at the website mentioned i.e.http://www.nepalstock.com.np/main/floorsheet/index/${!loop}/ . Also suggest solutions (if there are any) to change the default results from 20 to 500.

I used nested loops all the time. What goes wrong in your case?

I have attached the equivalent nested for using two while loops. During the execution, the log indicates the problem in while command #4

{
  "CreationDate": "2021-5-25",
  "Commands": [
    {
      "Command": "open",
      "Target": "http://www.nepalstock.com.np/main/floorsheet/index/${!loop}/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "3",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "3",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${tr}<=22)",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${td}<=8)",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//*[@id=\"home-contents\"]/table/tbody/tr[${tr}]/td[${td}]",
      "Value": "!csvLine",
      "Description": ""
    },
    {
      "Command": "csvSave",
      "Target": "nepsedata",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "${td}+1",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "${tr}+1",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

Yes, you will get: [error] [Line 1]Unclosed ‘while_v2’ (at command #4)

=> You are missing an “END” for the 2nd loop!

1 Like

Also:

  • STORE can not be used to do math operations. You must use executeScript_Sandbox for this

  • ${td}+1 adds two strings! To do math, use Number (${td}) +1

=> This macro works:

{
  "Name": "test",
  "CreationDate": "2021-5-26",
  "Commands": [
    {
      "Command": "comment",
      "Target": "open // http://www.nepalstock.com.np/main/floorsheet/index/${!loop}/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "3",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "3",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${tr}<=22)",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${td}<=8)",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "store // ${td}+1",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${td})+1;",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "store // ${tr}+1",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${tr})+1;",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}
1 Like

I don’t know what is the problem but your macro is not ending anywhere. Have you tried running the macro on your device?

Oh, a small mistake. The second variable increment must be in the outer loop.

This works:

{
  "Name": "loop1",
  "CreationDate": "2021-5-30",
  "Commands": [
    {
      "Command": "store",
      "Target": "3",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "3",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "(${tr}<22)",
      "Value": "",
      "Description": "outer loop"
    },
    {
      "Command": "while_v2",
      "Target": "(${td}<8)",
      "Value": "",
      "Description": "inner loop"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${td})+1;",
      "Value": "td",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": "inner"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${tr})+1;",
      "Value": "tr",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": "outer"
    }
  ]
}