Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IIF()
Message
From
28/04/1998 00:19:30
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: IIF()
Miscellaneous
Thread ID:
00095089
Message ID:
00095299
Views:
22
Hi George:

Good work on the recent MVP stuff :)



>>Hello,
>> Is an IIF() faster than an If-Else-Endif statement?
>
>As has been stated, yes it is. However, Bret's readability point is an excellent one. Unless conditions exist that make it absolutely necessary (in a loop with a large number of iterations, for example), my feeling is the the speed difference is so minimal, that using the IF/ELSE/ENDIF block is the way to go.
>
>Personally, I tend to use IIF() only in reports and in queries.

I'm an IIF() junkie. I never nest them (which would be REALLY unreadable) but I like to use them in simple, logical settings where the traditional IF..ENDIF is almost a waste of codespace....for example:

I'd much rather use:

nCurrentRecord=IIF(EOF('table'),0,RECNO('table'))

Than:

IF EOF('table')
nCurrentRecord = 0
ELSE
nCurrentRecord = RECNO('table')
ENDIF

It just feels right :)
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform