Skip to content

Conditions & Loops

TagUI Word Plugin Toolbar

Using conditions and loops provides scripts with intelligence that is usual in software applications.

Conditions

The IF statement is the way to make a decision in a script. For example you may want a script to run based on a certain parameter e.g. if a specific website is visited but want a different script run if another website is visited.

TagUI makes it relatively simple to implement these decisions. Indenting the code is important for IF to be correctly interpreted.

If Condition

https://verdapress.uk/services/test-bed/

if url() contains "services"
  https://google.com
  wait 2
else
  https://msn.com
  wait 2

Loops

Running a script (in a loop) a number of times based on specific value or on the amount of data available is a common RPA or coding function.

For Loop

for n from 1 to 3
  echo `n`
  wait 2

The code can be run from a tag file e.g. forloop.tag:

tagui forloop.tag -n -q

The -n (no browser) switch runs without launching a web browser

The -q (quiet) switch run a script without output except for explicit output (echo, show, check steps and errors etc.)