Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is ASSERT used for?
Message
De
29/09/1998 08:34:50
 
 
À
28/09/1998 19:09:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00141677
Message ID:
00141860
Vues:
32
>I recently aquired Visual Studio 6 and I bought a copy of FoxPro Advisor with that (October issue).
>
>In his article about the report-wrapper class (p.41 to 49), Chistof Lange uses the ASSERT command (like ASSERT TYPE("tcOption") == "C").
>
>I fail to see what this command does, and VFP's help isn't helping...
>
>Anyone care to elaborate?

ASSERT checks a condition, and if it isn´t true, shows up an error message. (There even is a MESSAGE option to allow for your own text.)

We use ASSERT regularly to check for all "expected" conditions. For example, all routines verify that their parameters are of the correct type (as in the FP Advisor example). We also use ASSERTs in DO CASE structures as shown:
DO CASE
CASE condition1
...
CASE condition2
...
...
OTHERWISE
ASSERT .F.
ENDCASE
We try to check for all conditions in the CASE (even if it means that some CASE will have no associated code) so the OTHERWISE clause should never be executed.

Believe me, I will use anything that helps avoiding errors!!

HTH!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform