How do I pass many parameters from VB.Net to a macro?

We pass over 10 parameters to our iMacros programmatically using VB.Net, some of which are long text. They are used to fill a form. Do you have any plans to introduce similar functionality in your product? I read that you can pass 3 parameters thru the command line, or read more from a text file, but neither one of these are adequate. Saving sensitive parameters to a text file, as well as issues with having carriage returns in a text in a csv file make the second option unappealing. We are considering switching from iMacros to your product. Thank you.

You can pass infinite parameters via url and then extrapolate them as you like and save them in separate variables.

You don’t need to rely on the default variables since you can create the url as you prefer and then save the individual parts in variables of your choice

1 Like

Correct, ui.vision can send only cmd_var1, cmd_var2 and cmd_var3. These variable names are fixed.

But as @newuserkantu mentioned, there is a good workaround. You can combine all your 10+ values into one long string, and then, inside the macro, split the string into its part again:

In the macro below I show how it is done. Assume !cmd_var1 would contain this string:

aaaaaaXXX111\n\bbbbXXX1 2 3 4 5XXXChinese你好XXXLong text: The Send-MailMessage cmdlet uses the From parameter to specify the message’s sender. The To parameter specifies the message’s recipient. The Subject parameter uses the text string Test mail as the message because the optional Body parameter is not includedXXXthis works.

and then inside the macro split the string at XXX. So now the array (“a” in the macro below) contains the separate values.

You can now use e. g. forEach to loop over this array, or get your values with the [x] array notation:

  • echo | Value1 is ${a[0]}
  • echo | Value2 is ${a[1]}
  • echo | Value30 would be in ${a[29]}

Result:

split string

Macro:

{
  "Name": "split string",
  "CreationDate": "2023-2-7",
  "Commands": [
    {
      "Command": "store",
      "Target": "aaaaaaXXX111\\n\\bbbbXXX1 2 3 4 5XXXChinese你好XXXLong text: The Send-MailMessage cmdlet uses the From parameter to specify the message's sender. The To parameter specifies the message's recipient. The Subject parameter uses the text string Test mail as the message because the optional Body parameter is not includedXXXthis works.",
      "Value": "var1",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "s = ${var1}; myArray = s.split(\"XXX\"); return myArray;",
      "Value": "a",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "a",
      "Value": "value",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Value is: ${value}",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "You can also access the array values this way:",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Value1 = ${a[0]}",
      "Value": "blue",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Value2 = ${a[1]}",
      "Value": "pink",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Value3 = ${a[2]}",
      "Value": "brown",
      "Description": ""
    }
  ]
}
3 Likes

Ok, thank you all for your response. I will have to study your posts since I am new to the product.

Congrats you’ve created some really excellent macro code

1 Like