[thelist] ASP - if x = every nth?
Phil Turmel
pturmel-webdev at turmel.org
Wed Jun 6 12:04:22 CDT 2007
Matt Warden wrote:
> On 6/6/07, Jon Hughes <hughesj at firemtn.com> wrote:
>
>>Thank you all for that :)
>>
>>What about if it's not even?
>>
>>Example:
>>
>>if i = 4 or i = 9 or i = 14 or i = 19 or i = 24 or i = 29 or i = 34 or i
>>= 39 or i = 44 or i = 49 then
>>
>>if (I mod 4) = 0 then
>>
>>does not do the same thing.
>
>
> That is because you are not asking the same question. You have an
> offset, so you must include that in the calculation.
>
> if (i - 4) mod 5 = 0 then
>
Jon,
For readability when the offset is a constant, I'd move the
offset to the right of the equals, like so:
if i mod 5 = 4 then
You are skipping by fives, so there's only five possibilities:
0,5,10,15,... "if i mod 5 = 0 then"
1,6,11,16,... "if i mod 5 = 1 then"
2,7,12,17,... "if i mod 5 = 2 then"
3,8,13,18,... "if i mod 5 = 3 then"
4,9,14,19,... "if i mod 5 = 4 then"
HTH,
Phil
More information about the thelist
mailing list