IF = Odd Number

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

IF = Odd Number

Post by RNIB » Tue Mar 15, 2016 10:45 am

I'm trying to write a macro where I have the line:

Input>part_no,Please Enter the Part Number,1

Is it possible to use an IF command so that if the part_no = an odd number it does one thing and if it's an even number it does something else? I can't work out how to get it to identify odd and even numbers.

If this is not possible, is it possible to use a number of values to compare against like:

IF>%part_no%=1,3,5,7,9,11,13

shapowsky
Newbie
Posts: 11
Joined: Sun Mar 06, 2016 9:29 am

Re: IF = Odd Number

Post by shapowsky » Tue Mar 15, 2016 12:46 pm

Well, I don't find anything that convert int to string here and I don't know how to work with VBS in MS.

Btw, you only need:
value/2
convert to string the result
if result = "*,5" = odd

Sorry for not help you.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: IF = Odd Number

Post by JRL » Tue Mar 15, 2016 12:49 pm

Same thing only different.

Code: Select all

//If answer = 1 the number is odd
//If answer =0 the number is even
//Mod only works with whole numbers
Let>number=23
Let>answer={%number%mod(2)}
MDL>answer

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: IF = Odd Number

Post by RNIB » Tue Mar 15, 2016 1:04 pm

Cheers all.

I think I've got it working with this:

Let>x={%part_no% mod 2}
IF>x=0
//Even
Else
//Odd
ENDIF

It seems to be working but if anyone see's a problem with it please let me know as I'm not an expert in this stuff.

jacobcarl
Newbie
Posts: 2
Joined: Mon May 02, 2016 9:42 am
Contact:

Re: IF = Odd Number

Post by jacobcarl » Thu May 12, 2016 11:12 am

how about else IF ? does it work too ?

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