Looping through a number of tests

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Carnivean
Newbie
Posts: 17
Joined: Fri Jun 10, 2011 8:04 am

Looping through a number of tests

Post by Carnivean » Thu Jul 14, 2011 12:59 pm

Hi

I'm trying without success to have my script loop through a number of cycles then go off and do something then come back and continue looping for another set of cycles, as below:

If>Count={(500) OR (1000) OR (1500)
Goto>Elsewhere
EndIf

I'm obviously doing something wrong so any help is appreciated

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jul 14, 2011 1:11 pm

I think you mean:

Code: Select all

If>{(%Count%=500) OR (%Count%=1000) OR (%Count%=1500)}
  Goto>Elsewhere
EndIf
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Carnivean
Newbie
Posts: 17
Joined: Fri Jun 10, 2011 8:04 am

Post by Carnivean » Thu Jul 14, 2011 1:25 pm

Thanks thats exactly what I was trying to do

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jul 14, 2011 1:41 pm

If you are wondering why your code didn't work let's take a closer look at it:

If>Count={(500) OR (1000) OR (1500)}

I've added the missing "}" at the end

What does the above say? Well we have an expression on the right of an equals sign so we are asking if Count is equal to the result of that expression.

So let's look at that expression on it's own:

{(500) OR (1000) OR (1500)}

What does that mean?

There are no boolean expressions - no comparisons. There are only numbers so the OR is operating on those numbers. It will do a mathematical OR - a "bitwise" OR. It will compare each bit of each number and OR each one.

So let's convert each number to binary and OR the bits:

500: 111110100
1000: 1111101000
1500: 10111011100

Using a table to see how we OR each bit (any column that contains a 1 results in a 1):

0500: | | | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0
1000: | | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0
1500: | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0

Res: | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0
Edit: sorry, can't get the table to line up, but hopefully you get the idea.

Result is 11111111100 which is decimal 2044

Easy way to check this is do:

Let>x={(500) OR (1000) OR (1500)}

And you will see the debugger set x to 2044.

So, your code was saying:

Code: Select all

If>Count=2044
  Goto>Elsewhere
Endif
:-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Carnivean
Newbie
Posts: 17
Joined: Fri Jun 10, 2011 8:04 am

Post by Carnivean » Thu Jul 14, 2011 1:47 pm

Thanks again and I appreciate the explanation.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts