Quick intro guide - the '%' character

The percent character (i.e. ‘%’) is used a lot in WinAutomation. It can be really useful in Robin too.

It’s worth looking at this docs page first for using '$"%MyVar%" syntax for string interpolation, but we can do more with the percent character. The syntax isn’t quite the same as with WinAutomation, but is sufficiently similar to make a look at this page worthwhile. As it says there, everything that is contained within percentage signs will be calculated as a value.

This code shows we’re not limited to string variables using percent syntax.

Code itself:

# Provided formatting is properly done (i.e. $"%ValueToBeManipulated%"),
# everything that is contained within percentage signs will be calculated as a value.

comment Interpolation is described at \
https://robin-language.org/docs/robin-the-rpa-language/variables-manipulation/#text-concatenation-and-subtraction

# This webpage may be useful: https://support.softomotive.com/support/solutions/articles/35000088650-usage-of-the-character

set myvar to 42


Display.ShowMessage             Title:'A number variable prior to operation within percent signs       ' \
                                Message:$"%myvar%: The value of 'myvar', a number variable." \
                                Icon:Display.Icon.None Buttons:Display.Buttons.OK \
                                DefaultButton:Display.DefaultButton.Button1 \
                                IsTopMost:False \
                                ButtonPressed=> ButtonPressed1

                                # Perform calculations INSIDE the '$"%%"' Sequence.
                                # Note the requirement for the '$' sign and DOUBLE quotes ("").

Display.ShowMessage             Title:'Variable calculation     ' \
                                Message:$"%myvar+22% is 'myvar' plus 22." \
                                Icon:Display.Icon.None Buttons:Display.Buttons.OK \
                                DefaultButton:Display.DefaultButton.Button1 \
                                IsTopMost:False \
                                ButtonPressed=> ButtonPressed2

                                # Set a number to text with a 'set' action,
                                # instead of using 'Text.FromNumber'

set myNumber to 0.99

set myNumberAsText to $"%myNumber%"

Display.ShowMessage             Title:'A number var as text using % notation     ' \
                                Message:myNumberAsText \
                                Icon:Display.Icon.None Buttons:Display.Buttons.OK \
                                DefaultButton:Display.DefaultButton.Button1 \
                                IsTopMost:False \
                                ButtonPressed=> ButtonPressed3

                                # We don't need the '$"%Var%"' syntax for text concat/subtract ops.

set myTextVar to "1594 Results"

set myTextVar to myTextVar- ' Results'

Console.Write                   Message: myTextVar

Hope this helps in some way!
Best regards,
burque505

2 Likes