###

» Wed Sep 07, 2011 1:45 pm

I know I might soon be called "grampa mod", but modulo is a perfect function to use here.

modulo returns the remains of the division of two numbers. If you divide a number by 2, and the number is even, it will have a remain of 0 (4/2 = 2, 5/2 = 2 remain 1)

if n % 2 = 0

-> number is even, do what you want to do to even numbered instances.

EDIT:

btw, this will also allow you to do much more versatile things. Set it to 3 instead of 2 to only change every third instance (3 % 3 = 0, 4 % 3 = 1, 5 % 3 = 2, 6 % 3 = 0, etc). Works with any other number as well, of course.tulamide2011-09-07 14:03:53