Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hate Nested IFs? Consider this...
Message
 
 
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:
01086317
Vues:
25
>>
>>SELECT c_letter_series_masters
>>DO CASE
>>   CASE myLookup("cDepartment_code=lcDepartment_code AND cClient_code=lcClient_hospital_id")
>>      lcLetter_series_masters_pk = c_letter_series_masters.cLetter_series_masters_pk
>>      llFound = .T.
>>   CASE myLookup("cDepartment_code = lcDepartment_code")
>>      lcLetter_series_masters_pk = c_letter_series_masters.cLetter_series_masters_pk
>>      llFound = .T.
>>   CASE myLookup("cClient_code = lcClient_hospital_id")
>>      lcLetter_series_masters_pk = cLetter_series_masters_pk
>>      llFound = .T.
>>   OTHERWISE
>>      =MESSAGEBOX("Nothing found")
>>      llFound = .F.
>>ENDCASE
>>
>>
>>FUNCTION myLookup
>>LPARAMETERS tcLookup
>>LOCATE FOR EVAL(tcLookup)
>>RETURN FOUND()
>>
>>
>
>LOL. I should have said without using functions. Also would you agree that this change would slow the code execution considerably if you're running this code in a loop? <g>

Two things -- I personally would not rewrite someone else's "nested IF" code as long as it did what it was expected to do. Second, the ONLY time I have gone to a DO CASE instead of the nested IFs is when I am calling methods within a class in order to do a massive amount of processing where I have to trap failures and prevent the execution of the subsequent CASE statements.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform