Create a global variable that will increment by 1 each time the macro is run


I would like to write a maco to populate a field with a value e.g. 100. Then if I run the macro again I would like it to be 101 and so on for many iterations.

So, I would like to know how to define a variable with a value and how to add 1 to that variable.


Here the solution simple add in front of var name global

Global var is a regular variable that expires when you close browser only

And for loops you can use times :

Thanks for the help… I got the variables and globalvariables to work… and it solved my one off problem.

The issues that come to mind are that

  1. the global variable does not work when the macro is called via a bookmark

  2. I got it to work by setting a global variable in the macro to 1, running the macro to create the global macro, then changing the line in the macro to add 1 to the global variable.
    Is there a way to define a global variable only if it does not exist.

thanks again

You can use alternative solution save in csv the value and use it.

I don’t understand your questions, what can’t you do?

1 Like
  1. it was necessary to open ui vision and click play macro… running the macro from a bookmark did not keep the global variable.

  2. If I repeatedly run a macro, where do I initially set the global variable value… if I set it in the macro then it will be reset on the next run… or can I ‘set global variable value if not exists’.

hope that explains it better

Probably you run macro via command line and after you close ui vision window and lost all variables in this mode.

If you see in ui vision tab variables you see the variables, check your global var from this tab if missing or is saved.

You do not close ui vision window and continue macro to manteiner global variables.

better solution is save it in csv…

1 Like