Logical Operations in WinAutomation

Feb 19 2010

Sometimes when you are creating a conditional, you may want to check if 2 conditions are simultaneously TRUE (or FALSE ). Some other times, you may want to execute a block of actions if at least one of the 2 conditions is true. WinAutomation allows you to perform basic logical operations with boolean variables. The logical connectives that are available in WinAutomation are the following:

Negation (not): !
Conjunction (and): &&
Disjunction (or): ||

Let's see an example so that it will be easier to understand how the logical operators work:

The task that we will try to automate is the following:
"We will prompt the user to enter a number between 0-100 and we will check whether the user's input is valid".

Our job should look like this:

Logical Operations in WinAutomation Sample

The First Operand of the "If" action is:
%UserInputAsNumber < 0 || UserInputAsNumber >100%
This expression can be translated as:
"If the number that the user input is smaller than zero OR greater than 100"

An equivalent expression that uses AND and NOT is the following:
%!(UserInputAsNumber > 0 && UserInputAsNumber < 100)%
This expression can be translated as:
"If the number that the user input is NOT greater than zero AND smaller than 100"

The 2 expressions above will have the same result: if the user enters a number that is smaller than 0 or greater than 100, the job will display an error message.

One last note: If you want to display the specific error message when the number is smaller than zero, greater than 100 and also when the number is equal to 50, then your expression should look like this:
%UserInputAsNumber < 0 || UserInputAsNumber >100 || UserInputAsNumber == 50%
Notice, that in order to check whether the %UserInputAsNumber% variable is equal to 50, you will need to use a double equal sign.

Your rating: None Average: 4 (4 votes)

Post your comment

You!
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may quote other posts using [quote] tags.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.