Check Variable for Odd or Even

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Dexter1
Pro Scripter
Posts: 64
Joined: Mon Jun 19, 2006 3:28 pm

Check Variable for Odd or Even

Post by Dexter1 » Fri Oct 17, 2008 8:14 pm

I want to evaluate the following to see if the user has entered an odd or even number, is this possble?

Code: Select all

Input>WeekNumber, Enter Week Number
Thanks,
Josh

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

Post by Marcus Tettmar » Fri Oct 17, 2008 8:46 pm

Mod by 2 and if the remainder is 0 it must be even:

Code: Select all

Let>weekNumber=5
Let>x={%weekNumber% mod 2}

If>x=0
  //even
Else
  //odd
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?

Dexter1
Pro Scripter
Posts: 64
Joined: Mon Jun 19, 2006 3:28 pm

Post by Dexter1 » Fri Oct 17, 2008 8:56 pm

w00t! That works like a champ.

Thanks,
Josh
Thanks,
Josh

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