Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Huge table and seek/indexseek commands
Message
De
10/08/2002 08:54:02
Walter Meester
HoogkarspelPays-Bas
 
 
À
09/08/2002 14:21:08
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00687800
Message ID:
00688287
Vues:
54
Hi hilmar,

>OK, here is one "contest": you have to run three functions one after the other. func2() should only run if func1() is successful, and func3(), again, depends on the successful completion of func2(). Do you see an alternative that is shorter than two nested IFs?

That's too easy,
= Func(1) AND Func(2) AND Func(3)
Or if you want a more structured way in handling failures:
DO CASE
   CASE !Func(1)
        ** Handle exception here

   CASE !Func(2)
        ** Handle exception here

   CASE !Func(3)
        ** Handle exception here

   OTHERWISE
        ** All functions succeeded
ENDCASE
Some might argue that the latter is a bad coding practise as the CASE lines cannot be moved from one position to another. OTOH, this practise does help to avoid nested IFs and IMO does produce more readable code.

Walter,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform