>Kirk,
>
>I see that others have posted and said that IIF is faster than IF...ENDIF.
>
>I disagree!
>
>I remember testing this in the past and I've always found IF...ENDIF to be faster. I just ran another test using your example and as I expected, I found IF...ENDIF to be faster.
>
>Here's what I did:
>
>#DEFINE MAXLOOPS 1000000
>ldStartOn = DATE()
>lnStart = SECONDS()
>FOR x = 1 TO MAXLOOPS
> ldStartOn = ldStartOn + IIF(VARTYPE(ldStartOn)=[D],1,86400)
>ENDFOR
>lnEnd = SECONDS()
>MESSAGEBOX('IIF: ' + TRANSFORM(lnEnd-lnStart))
>
>
>lnStart = SECONDS()
>FOR x = 1 TO MAXLOOPS
> IF VARTYPE(ldStartOn)=[D]
> ldStartOn=ldStartOn+1
> ELSE
> ldStartOn=ldStartOn+86400
> ENDIF
>ENDFOR
>lnEnd = SECONDS()
>MESSAGEBOX('IF-ENDIF: ' + TRANSFORM(lnEnd-lnStart))
>
>
Guy,
Hmmm...I could've sworn that at one time I read that IIF() was faster. Maybe it was "conventional wisdom" that no longer applies.
I do, however, have a couple of questions.
First, what were the actual results?
Second, how many times did you run the test and were the results consistent?
Third, did you have anything else other than VFP running at the time?
George
Ubi caritas et amor, deus ibi est