Usage of the % character

The percentage sign (%) is used as a special character. Its most commonly seen use is to denote variables (%MyVar%), however its role is much more versatile, and it is crucial to understand.

To put it simply, everything that is contained within percentage signs will be "calculated" as a value; otherwise, it will be treated as text.

Percentage sign variable properties

In this context, variable names within percentage signs will be replaced by their values. Note that multiple variables may be included between two percentage signs; adding more than two percentage signs will cause a syntax error.

Replacing percentage sign as variables properties

Setting percentage sign variables properties

Multiple variables, numbers etc. can be part of a single calculation:

Setting multiple percentage sign variables properties

In some cases, however, the percentage sign should be used as a simple character, and not to denote a calculation. In those cases, the percent sign should be escaped, using the backslash (\).

Escaping percentage variables

Special care should be taken in some cases, for example when using variables within file paths:

Using percentage signs within file paths

The above will fail, because the first percentage sign will be escaped by the backslash. To avoid this, we must escape the backslash itself:

Escaping percentage signs within file paths

In this way, the backslash will be considered an ordinary character, and the variable will be used correctly.

Keep in mind that some actions which have URL fields will automatically escape the percentage sign when they detect a URL, in order to facilitate user input.

Escaping percentage signs within user input fields

Therefore, if you need to use a variable in a URL, it is best to assign the entire URL to a new variable beforehand, and enter that as input instead.

Creating URL variables

In case you want to pass a number in WinAutomation as a text type variable instead of numerical type, you need to use the following configuration:

Creating variable to convert number to text

If you need to remove one or more characters from a text type variable, you need to use the %""% representation in the 'Replace Text' action:

Replace text variable configuration properties