How to create a function and call it

Good I have this code, and I want to turn it into a function as I have to do.

{
  "Name": "pruieba",
  "CreationDate": "2024-6-6",
  "Commands": [
    {
      "Command": "store",
      "Target": "fast",
      "Value": "!replayspeed",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "/html/body/div[8]/main/section/section/div[5]/div/div[3]/div[2]/div/div/div/div/div[1]/div/div/div/div[2]/a/span",
      "Value": "DatoAComproabar",
      "Description": ""
    },
    {
      "Command": "if",
      "Target": "${DatoAComproabar} == 'Lección'",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "ID Lección is present.",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "if",
      "Target": "${DatoAComproabar} == 'Transportar hierro'",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "ID Transportar hierro is present. 02 ",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "if",
      "Target": "${DatoAComproabar} == 'Silvicultura'",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "ID Silvicultura is present. 03",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Check completed.",
      "Value": "",
      "Description": ""
    }
  ]
}

Also how I make this function from another macro

There is nothing to do. You can call it from another macro with

RUN | pruieba

That is all! Variables from the main program are visible in the function, too.

1 Like

Thank you very much for the help and the time you have dedicated to me.