Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hate Nested IFs? Consider this...
Message
De
12/01/2006 14:18:52
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01086217
Message ID:
01086231
Vues:
9
Woudn't using OR instead of AND allow for a failure at any level also?

>no nesting or NOTs needed
>
>
>llSuccess = 1st_Logical_Test and 2nd_Logical_Test and 3rd_Logical_Test
>
>
>which I think is much clearer code to indicate overall success is dependent on each individual test being .t.
>
>>I took this from your comments in the GLGDW thread...
>>
>>>Some people hate (with a capital H) nesting of IFs simply because they can't stand the indenting. I don't worry about how much indenting is done.
>>
>>Here is a tip as an alternate to nested IFs that I use just because it is easier for ME to follow:
>>
>>local llSuccess
>>llSuccess = .T.
>>DO CASE
>>   CASE NOT 1st_Logical_Test
>>       llSuccess = .F.
>>   CASE NOT 2nd_Logical_Test
>>       llSuccess = .F.
>>   CASE NOT 3rd_Logical_Test
>>       llSuccess = .F.
>>   OTHERWISE
>>       llSuccess = .T.
>>ENDCASE
>>RETURN llSuccess
>>Just remove the "llSuccess = .F." lines above or the "OTHERWISE" clause depending on your preference. That DO CASE is the same as --
>>LOCAL llSuccess
>>llSuccess = .F.
>>IF 1st_Logical_Test
>>   IF 2nd_Logical_Test
>>      IF 3rd_Logical_Test
>>         llSuccess = .T.
>>      ENDIF
>>   ENDIF
>>ENDIF
>>RETURN llSuccess
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform