Reader's Clinic - Scaled Masked Decimal Conversions
QTIPS - FOR/NEXT variables
@ATTACK - @Modal
Reader's Clinic - Page Marks in Windows

RevMedia FKB

DocumentV4I2A5
TitleQTIPS - FOR/NEXT variables
KeywordsFOR
NEXT
STEP
TextTony McDowell writes "The documentation (page N4 73) states that "start"
"end" and "step" must be integers A little experimentation might suggest
that in fact any decimal fractions can be used for these VARIABLES Don't be
fooled If STEP is a decimal fraction then anomalous results can occur
Specifically it seems that the "even ness" of the BOUND and step variables
is critical My tests show that if step and the lower and upper bounds are
"even" decimal fractions then the FOR/NEXT LOOP will incorrectly terminate
when step is equal to "end" rather than when it exceeds "end" (or underflows
if step is negative) "

* This one is bad it won't hit 2 0
A = 2 ; B = 2
For I = A To B Step 0 2 ; Call Msg("I = " : I) ; Next

* This one is OK
A = 1 ; B = 1
For I = A To B Step 0 2 ; Call Msg("I = " : I) ; Next

* This one OK
A = 2 ; B = 4
For I = A To B Step 0 5 ; Call Msg("I = " : I) ; Next

* This one is bad it won't hit 4 0
A = 2 ; B = 4
For I = A To B Step 0 4 ; Call Msg("I = " : I) ; Next

* NB Version 2 12 MSG used above!


(Volume 4 Issue 2 Page 5)
[revmedia/copyrigh.htm]

Page last modified: 08/02/03