Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nested IIF()'s Versus ICASE()
Message
De
03/03/2008 20:19:01
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01298206
Message ID:
01298308
Vues:
25
>>I am pretty sure that Icase is faster, but whether the difference is significant or not, I don't know. But the improved readability can be translated into improved maintainability, and that's enough for me. I have been able to tidy up some rally messy code.
>
>I agree. I'm in the camp that like to maintain clean code.

Here's an example of ICase() translated into nested iif()s, while trying to keep the readability
#IF hV9
	lnA=ICASE(lnB=0,0,	;
		lnB=1,1,	;
		INLIST(lnB,2,3,5),3,	;
		INLIST(lnB,6,7),4,	;
		lnB=4,7,	;
		0)
#ELSE
	lnA=IIF(lnB=0,0,	;
		IIF(lnB=1,1,	;
		IIF(INLIST(lnB,2,3,5),3,	;
		IIF(INLIST(lnB,6,7),4,	;
		IIF(lnB=4,7,	;
		0)))))
#ENDIF
The conversion from the above to the below turned out to be just inserting iif( in front of every expression, then closing parentheses in the end. This way they look just equally readable to me... though Icase() is nicer.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform